forked from hub4j/github-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGHTagTest.java
More file actions
61 lines (49 loc) · 1.76 KB
/
Copy pathGHTagTest.java
File metadata and controls
61 lines (49 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package org.kohsuke.github;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
*/
public class GHTagTest extends AbstractGitHubWireMockTest {
@Before
@After
public void cleanUpTags() throws Exception {
// Cleanup is only needed when proxying
if (!mockGitHub.isUseProxy()) {
return;
}
try {
GHRef ref = getRepository(this.getGitHubBeforeAfter()).getRef("tags/create_tag_test");
if (ref != null) {
ref.delete();
}
} catch (IOException e) {
// The reference probably does not exist.
// This is safe to ignore.
}
}
@Test
public void testCreateTag() throws Exception {
GHRepository repo = getRepository();
String commitSha = "dfe47235cfdcaa12292dab3b1a84ca53a1ceadaf";
String tagName = "create_tag_test";
String tagMessage = "Test Tag";
String tagType = "commit";
GHTagObject tag = repo.createTag(tagName, tagMessage, commitSha, tagType);
assertEquals(tagName, tag.getTag());
assertEquals(tagMessage, tag.getMessage());
assertEquals(commitSha, tag.getObject().getSha());
// Make a reference to the newly created tag.
GHRef ref = repo.createRef("refs/tags/" + tagName, tag.getSha());
assertNotNull(ref);
}
protected GHRepository getRepository() throws IOException {
return getRepository(gitHub);
}
private GHRepository getRepository(GitHub gitHub) throws IOException {
return gitHub.getOrganization("github-api-test-org").getRepository("github-api");
}
}