mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-04 15:50:52 +00:00
Enable part of AppTest in CI
This commit is contained in:
@@ -41,43 +41,46 @@ public class GitHubTest extends AbstractGitHubApiTestBase {
|
||||
|
||||
@Test
|
||||
public void testGitHubServerWithHttp() throws Exception {
|
||||
GitHub hub = GitHub.connectToEnterprise("http://enterprise.kohsuke.org/api/v3", "bogus","bogus");
|
||||
GitHub hub = GitHub.connectToEnterprise("http://enterprise.kohsuke.org/api/v3", "bogus", "bogus");
|
||||
assertEquals("http://enterprise.kohsuke.org/api/v3/test", hub.getApiURL("/test").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGitHubServerWithHttps() throws Exception {
|
||||
GitHub hub = GitHub.connectToEnterprise("https://enterprise.kohsuke.org/api/v3", "bogus","bogus");
|
||||
GitHub hub = GitHub.connectToEnterprise("https://enterprise.kohsuke.org/api/v3", "bogus", "bogus");
|
||||
assertEquals("https://enterprise.kohsuke.org/api/v3/test", hub.getApiURL("/test").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGitHubServerWithoutServer() throws Exception {
|
||||
GitHub hub = GitHub.connectUsingPassword("kohsuke", "bogus");
|
||||
assertEquals("https://api.github.com/test", hub.getApiURL("/test").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGitHubBuilderFromEnvironment() throws IOException {
|
||||
|
||||
Map<String, String>props = new HashMap<String, String>();
|
||||
|
||||
|
||||
Map<String, String> props = new HashMap<String, String>();
|
||||
|
||||
props.put("login", "bogus");
|
||||
props.put("oauth", "bogus");
|
||||
props.put("password", "bogus");
|
||||
|
||||
|
||||
setupEnvironment(props);
|
||||
|
||||
|
||||
GitHubBuilder builder = GitHubBuilder.fromEnvironment();
|
||||
|
||||
|
||||
assertEquals("bogus", builder.user);
|
||||
assertEquals("bogus", builder.oauthToken);
|
||||
assertEquals("bogus", builder.password);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Copied from StackOverflow: http://stackoverflow.com/a/7201825/2336755
|
||||
*
|
||||
*
|
||||
* This allows changing the in memory process environment.
|
||||
*
|
||||
*
|
||||
* Its used to wire in values for the github credentials to test that the GitHubBuilder works properly to resolve them.
|
||||
*/
|
||||
private void setupEnvironment(Map<String, String> newenv) {
|
||||
@@ -112,6 +115,7 @@ public class GitHubTest extends AbstractGitHubApiTestBase {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGitHubBuilderFromCustomEnvironment() throws IOException {
|
||||
Map<String, String> props = new HashMap<String, String>();
|
||||
@@ -154,8 +158,8 @@ public class GitHubTest extends AbstractGitHubApiTestBase {
|
||||
@Test
|
||||
public void listUsers() throws IOException {
|
||||
GitHub hub = GitHub.connect();
|
||||
for (GHUser u : Iterables.limit(hub.listUsers(),10)) {
|
||||
assert u.getName()!=null;
|
||||
for (GHUser u : Iterables.limit(hub.listUsers(), 10)) {
|
||||
assert u.getName() != null;
|
||||
System.out.println(u.getName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user