Skip to content

Commit a4f42b2

Browse files
committed
Add more tests from AppTest
1 parent cb2fcd3 commit a4f42b2

319 files changed

Lines changed: 372353 additions & 50 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/test/java/org/kohsuke/github/AppTest.java

Lines changed: 11 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,11 @@ public void testRepoPermissions() throws Exception {
290290
assertFalse(r.hasAdminAccess());
291291
}
292292

293-
@Ignore("Needs mocking check")
294293
@Test
295294
public void testGetMyself() throws Exception {
296295
GHMyself me = gitHub.getMyself();
297296
assertNotNull(me);
298-
assertNotNull(gitHub.getUser("kohsuke2"));
297+
assertNotNull(gitHub.getUser("bitwiseman"));
299298
PagedIterable<GHRepository> ghRepositories = me.listRepositories();
300299
assertTrue(ghRepositories.iterator().hasNext());
301300
}
@@ -315,29 +314,25 @@ public void testOrgFork() throws Exception {
315314
gitHub.getRepository("kohsuke/rubywm").forkTo(gitHub.getOrganization(GITHUB_API_TEST_ORG));
316315
}
317316

318-
@Ignore("Needs mocking check")
319317
@Test
320318
public void testGetTeamsForRepo() throws Exception {
321319
kohsuke();
322320
// 'Core Developers' and 'Owners'
323321
assertEquals(2, gitHub.getOrganization(GITHUB_API_TEST_ORG).getRepository("testGetTeamsForRepo").getTeams().size());
324322
}
325323

326-
@Ignore("Needs mocking check")
327324
@Test
328325
public void testMembership() throws Exception {
329326
Set<String> members = gitHub.getOrganization(GITHUB_API_TEST_ORG).getRepository("jenkins").getCollaboratorNames();
330327
System.out.println(members.contains("kohsuke"));
331328
}
332329

333-
@Ignore("Needs mocking check")
334330
@Test
335331
public void testMemberOrgs() throws Exception {
336332
HashSet<GHOrganization> o = gitHub.getUser("kohsuke").getOrganizations();
337333
assertThat(o, hasItem(hasProperty("name", equalTo("CloudBees"))));
338334
}
339335

340-
@Ignore("Needs mocking check")
341336
@Test
342337
public void testOrgTeams() throws Exception {
343338
kohsuke();
@@ -349,23 +344,20 @@ public void testOrgTeams() throws Exception {
349344
assertTrue(sz < 100);
350345
}
351346

352-
@Ignore("Needs mocking check")
353347
@Test
354348
public void testOrgTeamByName() throws Exception {
355349
kohsuke();
356350
GHTeam e = gitHub.getOrganization(GITHUB_API_TEST_ORG).getTeamByName("Core Developers");
357351
assertNotNull(e);
358352
}
359353

360-
@Ignore("Needs mocking check")
361354
@Test
362355
public void testOrgTeamBySlug() throws Exception {
363356
kohsuke();
364357
GHTeam e = gitHub.getOrganization(GITHUB_API_TEST_ORG).getTeamBySlug("core-developers");
365358
assertNotNull(e);
366359
}
367360

368-
@Ignore("Needs mocking check")
369361
@Test
370362
public void testCommit() throws Exception {
371363
GHCommit commit = gitHub.getUser("jenkinsci").getRepository("jenkins").getCommit("08c1c9970af4d609ae754fbe803e06186e3206f7");
@@ -385,12 +377,10 @@ public void testCommit() throws Exception {
385377
assertNotNull(t.getEntry("war").asTree());
386378
}
387379

388-
@Ignore("Needs mocking check")
389380
@Test
390381
public void testListCommits() throws Exception {
391382
List<String> sha1 = new ArrayList<String>();
392383
for (GHCommit c : gitHub.getUser("kohsuke").getRepository("empty-commit").listCommits()) {
393-
System.out.println(c.getSHA1());
394384
sha1.add(c.getSHA1());
395385
}
396386
assertEquals("fdfad6be4db6f96faea1f153fb447b479a7a9cb7", sha1.get(0));
@@ -416,7 +406,6 @@ public void testBranches() throws Exception {
416406
System.out.println(b);
417407
}
418408

419-
@Ignore("Needs mocking check")
420409
@Test
421410
public void testCommitComment() throws Exception {
422411
GHRepository r = gitHub.getUser("jenkinsci").getRepository("jenkins");
@@ -428,7 +417,6 @@ public void testCommitComment() throws Exception {
428417
}
429418
}
430419

431-
@Ignore("Needs mocking check")
432420
@Test
433421
public void testCreateCommitComment() throws Exception {
434422
GHCommit commit = gitHub.getUser("kohsuke").getRepository("sandbox-ant").getCommit("8ae38db0ea5837313ab5f39d43a6f73de3bd9000");
@@ -439,7 +427,6 @@ public void testCreateCommitComment() throws Exception {
439427
c.delete();
440428
}
441429

442-
@Ignore("Needs mocking check")
443430
@Test
444431
public void tryHook() throws Exception {
445432
kohsuke();
@@ -555,7 +542,6 @@ private void testPostCommitHook(GitHub gitHub) throws IOException {
555542
System.out.println(hooks);
556543
}
557544

558-
@Ignore("Needs mocking check")
559545
@Test
560546
public void testOrgRepositories() throws IOException {
561547
kohsuke();
@@ -566,7 +552,6 @@ public void testOrgRepositories() throws IOException {
566552
System.out.printf("%d repositories in %dms\n", repos.size(), end - start);
567553
}
568554

569-
@Ignore("Needs mocking check")
570555
@Test
571556
public void testOrganization() throws IOException {
572557
kohsuke();
@@ -578,7 +563,6 @@ public void testOrganization() throws IOException {
578563
// t.add(labs.getRepository("xyz"));
579564
}
580565

581-
@Ignore("Needs mocking check")
582566
@Test
583567
public void testCommitStatus() throws Exception {
584568
GHRepository r = gitHub.getRepository("github-api/github-api");
@@ -594,7 +578,6 @@ public void testCommitStatus() throws Exception {
594578
assertEquals("http://kohsuke.org/", state.getTargetUrl());
595579
}
596580

597-
@Ignore("Needs mocking check")
598581
@Test
599582
public void testCommitShortInfo() throws Exception {
600583
GHRepository r = gitHub.getRepository("github-api/github-api");
@@ -612,7 +595,6 @@ public void testPullRequestPopulate() throws Exception {
612595
assertNotNull(u.getName());
613596
}
614597

615-
@Ignore("Needs mocking check")
616598
@Test
617599
public void testCheckMembership() throws Exception {
618600
kohsuke();
@@ -667,14 +649,12 @@ public void testCreateRelease() throws Exception {
667649
}
668650
}
669651

670-
@Ignore("Needs mocking check")
671652
@Test
672653
public void testRef() throws IOException {
673654
GHRef masterRef = gitHub.getRepository("jenkinsci/jenkins").getRef("heads/master");
674-
assertEquals("https://api.github.com/repos/jenkinsci/jenkins/git/refs/heads/master", masterRef.getUrl().toString());
655+
assertEquals(mockGitHub.apiServer().baseUrl() + "/repos/jenkinsci/jenkins/git/refs/heads/master", masterRef.getUrl().toString());
675656
}
676657

677-
@Ignore("Needs mocking check")
678658
@Test
679659
public void directoryListing() throws IOException {
680660
List<GHContent> children = gitHub.getRepository("jenkinsci/jenkins").getDirectoryContent("core");
@@ -770,7 +750,6 @@ public void testTrees() throws IOException {
770750
assertTrue(foundReadme);
771751
}
772752

773-
@Ignore("Needs mocking check")
774753
@Test
775754
public void testTreesRecursive() throws IOException {
776755
GHTree masterTree = gitHub.getRepository("github-api/github-api").getTreeRecursive("master", 1);
@@ -851,42 +830,32 @@ void cleanupLabel(String name) {
851830
}
852831
}
853832

854-
@Ignore("Needs mocking check")
855833
@Test
856834
public void testSubscribers() throws IOException {
857-
boolean kohsuke = false;
858-
GHRepository mr = gitHub.getRepository("github-api/github-api");
835+
boolean bitwiseman = false;
836+
GHRepository mr = gitHub.getRepository("bitwiseman/github-api");
859837
for (GHUser u : mr.listSubscribers()) {
860-
System.out.println(u.getLogin());
861-
kohsuke |= u.getLogin().equals("kohsuke");
838+
bitwiseman |= u.getLogin().equals("bitwiseman");
862839
}
863-
assertTrue(kohsuke);
864-
System.out.println("---");
840+
assertTrue(bitwiseman);
865841

866-
boolean githubApi = false;
867-
for (GHRepository r : gitHub.getUser("kohsuke").listRepositories()) {
868-
System.out.println(r.getName());
869-
githubApi |= r.equals(mr);
842+
boolean githubApiFound = false;
843+
for (GHRepository r : gitHub.getUser("bitwiseman").listRepositories()) {
844+
githubApiFound |= r.equals(mr);
870845
}
871-
assertTrue(githubApi);
846+
assertTrue(githubApiFound);
872847
}
873848

874-
@Ignore("Needs mocking check")
875849
@Test
876850
public void notifications() throws Exception {
877851
boolean found = false;
878852
for (GHThread t : gitHub.listNotifications().nonBlocking(true).read(true)) {
879853
if (!found) {
880854
found = true;
881-
t.markAsRead(); // test this by calling it once on old nofication
855+
t.markAsRead(); // test this by calling it once on old notfication
882856
}
883857
assertNotNull(t.getTitle());
884858
assertNotNull(t.getReason());
885-
886-
System.out.println(t.getTitle());
887-
System.out.println(t.getLastReadAt());
888-
System.out.println(t.getType());
889-
System.out.println();
890859
}
891860
assertTrue(found);
892861
gitHub.listNotifications().markAsRead();
@@ -905,7 +874,6 @@ public void checkToString() throws Exception {
905874
System.out.println(r.getIssue(1));
906875
}
907876

908-
@Ignore("Needs mocking check")
909877
@Test
910878
public void reactions() throws Exception {
911879
GHIssue i = gitHub.getRepository("github-api/github-api").getIssue(311);
@@ -921,23 +889,16 @@ public void reactions() throws Exception {
921889
a.delete();
922890
}
923891

924-
@Ignore("Needs mocking check")
925892
@Test
926893
public void listOrgMemberships() throws Exception {
927894
GHMyself me = gitHub.getMyself();
928895
for (GHMembership m : me.listOrgMemberships()) {
929896
assertThat(m.getUser(), is((GHUser) me));
930897
assertNotNull(m.getState());
931898
assertNotNull(m.getRole());
932-
933-
System.out.printf("%s %s %s\n",
934-
m.getOrganization().getLogin(),
935-
m.getState(),
936-
m.getRole());
937899
}
938900
}
939901

940-
@Ignore("Needs mocking check")
941902
@Test
942903
public void blob() throws Exception {
943904
GHRepository r = gitHub.getRepository("github-api/github-api");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
{
2+
"id": 617210,
3+
"node_id": "MDEwOlJlcG9zaXRvcnk2MTcyMTA=",
4+
"name": "github-api",
5+
"full_name": "github-api/github-api",
6+
"private": false,
7+
"owner": {
8+
"login": "github-api",
9+
"id": 54909825,
10+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
11+
"avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
12+
"gravatar_id": "",
13+
"url": "https://api.github.com/users/github-api",
14+
"html_url": "https://github.com/github-api",
15+
"followers_url": "https://api.github.com/users/github-api/followers",
16+
"following_url": "https://api.github.com/users/github-api/following{/other_user}",
17+
"gists_url": "https://api.github.com/users/github-api/gists{/gist_id}",
18+
"starred_url": "https://api.github.com/users/github-api/starred{/owner}{/repo}",
19+
"subscriptions_url": "https://api.github.com/users/github-api/subscriptions",
20+
"organizations_url": "https://api.github.com/users/github-api/orgs",
21+
"repos_url": "https://api.github.com/users/github-api/repos",
22+
"events_url": "https://api.github.com/users/github-api/events{/privacy}",
23+
"received_events_url": "https://api.github.com/users/github-api/received_events",
24+
"type": "Organization",
25+
"site_admin": false
26+
},
27+
"html_url": "https://github.com/github-api/github-api",
28+
"description": "Java API for GitHub",
29+
"fork": false,
30+
"url": "https://api.github.com/repos/github-api/github-api",
31+
"forks_url": "https://api.github.com/repos/github-api/github-api/forks",
32+
"keys_url": "https://api.github.com/repos/github-api/github-api/keys{/key_id}",
33+
"collaborators_url": "https://api.github.com/repos/github-api/github-api/collaborators{/collaborator}",
34+
"teams_url": "https://api.github.com/repos/github-api/github-api/teams",
35+
"hooks_url": "https://api.github.com/repos/github-api/github-api/hooks",
36+
"issue_events_url": "https://api.github.com/repos/github-api/github-api/issues/events{/number}",
37+
"events_url": "https://api.github.com/repos/github-api/github-api/events",
38+
"assignees_url": "https://api.github.com/repos/github-api/github-api/assignees{/user}",
39+
"branches_url": "https://api.github.com/repos/github-api/github-api/branches{/branch}",
40+
"tags_url": "https://api.github.com/repos/github-api/github-api/tags",
41+
"blobs_url": "https://api.github.com/repos/github-api/github-api/git/blobs{/sha}",
42+
"git_tags_url": "https://api.github.com/repos/github-api/github-api/git/tags{/sha}",
43+
"git_refs_url": "https://api.github.com/repos/github-api/github-api/git/refs{/sha}",
44+
"trees_url": "https://api.github.com/repos/github-api/github-api/git/trees{/sha}",
45+
"statuses_url": "https://api.github.com/repos/github-api/github-api/statuses/{sha}",
46+
"languages_url": "https://api.github.com/repos/github-api/github-api/languages",
47+
"stargazers_url": "https://api.github.com/repos/github-api/github-api/stargazers",
48+
"contributors_url": "https://api.github.com/repos/github-api/github-api/contributors",
49+
"subscribers_url": "https://api.github.com/repos/github-api/github-api/subscribers",
50+
"subscription_url": "https://api.github.com/repos/github-api/github-api/subscription",
51+
"commits_url": "https://api.github.com/repos/github-api/github-api/commits{/sha}",
52+
"git_commits_url": "https://api.github.com/repos/github-api/github-api/git/commits{/sha}",
53+
"comments_url": "https://api.github.com/repos/github-api/github-api/comments{/number}",
54+
"issue_comment_url": "https://api.github.com/repos/github-api/github-api/issues/comments{/number}",
55+
"contents_url": "https://api.github.com/repos/github-api/github-api/contents/{+path}",
56+
"compare_url": "https://api.github.com/repos/github-api/github-api/compare/{base}...{head}",
57+
"merges_url": "https://api.github.com/repos/github-api/github-api/merges",
58+
"archive_url": "https://api.github.com/repos/github-api/github-api/{archive_format}{/ref}",
59+
"downloads_url": "https://api.github.com/repos/github-api/github-api/downloads",
60+
"issues_url": "https://api.github.com/repos/github-api/github-api/issues{/number}",
61+
"pulls_url": "https://api.github.com/repos/github-api/github-api/pulls{/number}",
62+
"milestones_url": "https://api.github.com/repos/github-api/github-api/milestones{/number}",
63+
"notifications_url": "https://api.github.com/repos/github-api/github-api/notifications{?since,all,participating}",
64+
"labels_url": "https://api.github.com/repos/github-api/github-api/labels{/name}",
65+
"releases_url": "https://api.github.com/repos/github-api/github-api/releases{/id}",
66+
"deployments_url": "https://api.github.com/repos/github-api/github-api/deployments",
67+
"created_at": "2010-04-19T04:13:03Z",
68+
"updated_at": "2019-10-25T01:32:16Z",
69+
"pushed_at": "2019-10-25T16:41:09Z",
70+
"git_url": "git://github.com/github-api/github-api.git",
71+
"ssh_url": "git@github.com:github-api/github-api.git",
72+
"clone_url": "https://github.com/github-api/github-api.git",
73+
"svn_url": "https://github.com/github-api/github-api",
74+
"homepage": "http://github-api.kohsuke.org/",
75+
"size": 13494,
76+
"stargazers_count": 565,
77+
"watchers_count": 565,
78+
"language": "Java",
79+
"has_issues": true,
80+
"has_projects": true,
81+
"has_downloads": true,
82+
"has_wiki": true,
83+
"has_pages": true,
84+
"forks_count": 433,
85+
"mirror_url": null,
86+
"archived": false,
87+
"disabled": false,
88+
"open_issues_count": 64,
89+
"license": {
90+
"key": "mit",
91+
"name": "MIT License",
92+
"spdx_id": "MIT",
93+
"url": "https://api.github.com/licenses/mit",
94+
"node_id": "MDc6TGljZW5zZTEz"
95+
},
96+
"forks": 433,
97+
"open_issues": 64,
98+
"watchers": 565,
99+
"default_branch": "master",
100+
"permissions": {
101+
"admin": true,
102+
"push": true,
103+
"pull": true
104+
},
105+
"allow_squash_merge": true,
106+
"allow_merge_commit": true,
107+
"allow_rebase_merge": true,
108+
"organization": {
109+
"login": "github-api",
110+
"id": 54909825,
111+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU0OTA5ODI1",
112+
"avatar_url": "https://avatars3.githubusercontent.com/u/54909825?v=4",
113+
"gravatar_id": "",
114+
"url": "https://api.github.com/users/github-api",
115+
"html_url": "https://github.com/github-api",
116+
"followers_url": "https://api.github.com/users/github-api/followers",
117+
"following_url": "https://api.github.com/users/github-api/following{/other_user}",
118+
"gists_url": "https://api.github.com/users/github-api/gists{/gist_id}",
119+
"starred_url": "https://api.github.com/users/github-api/starred{/owner}{/repo}",
120+
"subscriptions_url": "https://api.github.com/users/github-api/subscriptions",
121+
"organizations_url": "https://api.github.com/users/github-api/orgs",
122+
"repos_url": "https://api.github.com/users/github-api/repos",
123+
"events_url": "https://api.github.com/users/github-api/events{/privacy}",
124+
"received_events_url": "https://api.github.com/users/github-api/received_events",
125+
"type": "Organization",
126+
"site_admin": false
127+
},
128+
"network_count": 433,
129+
"subscribers_count": 48
130+
}

0 commit comments

Comments
 (0)