Skip to content

Commit afaff52

Browse files
committed
Removed test from GHRepositoryTest and added to GHTagTest.
1 parent 959eb46 commit afaff52

12 files changed

Lines changed: 756 additions & 37 deletions

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

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -344,41 +344,4 @@ public void getPostCommitHooks() throws Exception {
344344
assertThat(postcommitHooks.size(), equalTo(0));
345345
}
346346

347-
// @Before
348-
// @After
349-
// public void cleanUpTags() throws Exception {
350-
// // Cleanup is only needed when proxying
351-
// if (!mockGitHub.isUseProxy()) {
352-
// return;
353-
// }
354-
//
355-
// try {
356-
// GHRef ref = getRepository(this.gitHubBeforeAfter).getRef("tags/create_tag_test");
357-
// if (ref != null) {
358-
// ref.delete();
359-
// }
360-
// } catch (IOException e) {
361-
// // The reference probably does not exist.
362-
// // This is safe to ignore.
363-
// }
364-
// }
365-
366-
@Test
367-
public void testCreateTag() throws Exception {
368-
GHRepository repo = getRepository(gitHub);
369-
370-
String commitSha = "dfe47235cfdcaa12292dab3b1a84ca53a1ceadaf";
371-
String tagName = "create_tag_test";
372-
String tagMessage = "Test Tag";
373-
String tagType = "commit";
374-
375-
GHTagObject tag = repo.createTag(tagName, tagMessage, commitSha, tagType);
376-
assertEquals(tagName, tag.getTag());
377-
assertEquals(tagMessage, tag.getMessage());
378-
assertEquals(commitSha, tag.getObject().getSha());
379-
380-
// Make a reference to the newly created tag.
381-
GHRef ref = repo.createRef("refs/tags/" + tagName, tag.getSha());
382-
assertNotNull(ref);
383-
}
384347
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package org.kohsuke.github;
2+
3+
import org.junit.After;
4+
import org.junit.Before;
5+
import org.junit.Test;
6+
7+
import java.io.IOException;
8+
9+
import static org.junit.Assert.assertEquals;
10+
import static org.junit.Assert.assertNotNull;
11+
12+
/**
13+
*
14+
* @author Martin van Zijl
15+
*/
16+
public class GHTagTest extends AbstractGitHubWireMockTest {
17+
18+
@Before
19+
@After
20+
public void cleanUpTags() throws Exception {
21+
// Cleanup is only needed when proxying
22+
if (!mockGitHub.isUseProxy()) {
23+
return;
24+
}
25+
26+
try {
27+
GHRef ref = getRepository(this.gitHubBeforeAfter).getRef("tags/create_tag_test");
28+
if (ref != null) {
29+
ref.delete();
30+
}
31+
} catch (IOException e) {
32+
// The reference probably does not exist.
33+
// This is safe to ignore.
34+
}
35+
}
36+
37+
@Test
38+
public void testCreateTag() throws Exception {
39+
GHRepository repo = getRepository();
40+
41+
String commitSha = "dfe47235cfdcaa12292dab3b1a84ca53a1ceadaf";
42+
String tagName = "create_tag_test";
43+
String tagMessage = "Test Tag";
44+
String tagType = "commit";
45+
46+
GHTagObject tag = repo.createTag(tagName, tagMessage, commitSha, tagType);
47+
assertEquals(tagName, tag.getTag());
48+
assertEquals(tagMessage, tag.getMessage());
49+
assertEquals(commitSha, tag.getObject().getSha());
50+
51+
// Make a reference to the newly created tag.
52+
GHRef ref = repo.createRef("refs/tags/" + tagName, tag.getSha());
53+
assertNotNull(ref);
54+
}
55+
56+
protected GHRepository getRepository() throws IOException {
57+
return getRepository(gitHub);
58+
}
59+
60+
private GHRepository getRepository(GitHub gitHub) throws IOException {
61+
return gitHub.getOrganization("github-api-test-org").getRepository("github-api");
62+
}
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"login": "github-api-test-org",
3+
"id": 7544739,
4+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
5+
"url": "https://api.github.com/orgs/github-api-test-org",
6+
"repos_url": "https://api.github.com/orgs/github-api-test-org/repos",
7+
"events_url": "https://api.github.com/orgs/github-api-test-org/events",
8+
"hooks_url": "https://api.github.com/orgs/github-api-test-org/hooks",
9+
"issues_url": "https://api.github.com/orgs/github-api-test-org/issues",
10+
"members_url": "https://api.github.com/orgs/github-api-test-org/members{/member}",
11+
"public_members_url": "https://api.github.com/orgs/github-api-test-org/public_members{/member}",
12+
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
13+
"description": null,
14+
"is_verified": false,
15+
"has_organization_projects": true,
16+
"has_repository_projects": true,
17+
"public_repos": 10,
18+
"public_gists": 0,
19+
"followers": 0,
20+
"following": 0,
21+
"html_url": "https://github.com/github-api-test-org",
22+
"created_at": "2014-05-10T19:39:11Z",
23+
"updated_at": "2015-04-20T00:42:30Z",
24+
"type": "Organization",
25+
"total_private_repos": 0,
26+
"owned_private_repos": 0,
27+
"private_gists": 0,
28+
"disk_usage": 147,
29+
"collaborators": 0,
30+
"billing_email": "kk@kohsuke.org",
31+
"default_repository_permission": "none",
32+
"members_can_create_repositories": false,
33+
"two_factor_requirement_enabled": false,
34+
"plan": {
35+
"name": "free",
36+
"space": 976562499,
37+
"private_repos": 0,
38+
"filled_seats": 11,
39+
"seats": 0
40+
}
41+
}

0 commit comments

Comments
 (0)