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
89 lines (77 loc) · 2.64 KB
/
Copy pathGHTagTest.java
File metadata and controls
89 lines (77 loc) · 2.64 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package org.kohsuke.github;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import static org.hamcrest.Matchers.*;
// TODO: Auto-generated Javadoc
/**
* The Class GHTagTest.
*
* @author Martin van Zijl
*/
public class GHTagTest extends AbstractGitHubWireMockTest {
/**
* Clean up tags.
*
* @throws Exception
* the exception
*/
@Before
@After
public void cleanUpTags() throws Exception {
// Cleanup is only needed when proxying
if (!mockGitHub.isUseProxy()) {
return;
}
try {
GHRef ref = getRepository(this.getNonRecordingGitHub()).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 create tag.
*
* @throws Exception
* the exception
*/
@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);
assertThat(tag.getTag(), equalTo(tagName));
assertThat(tag.getMessage(), equalTo(tagMessage));
assertThat(tag.getObject().getSha(), equalTo(commitSha));
assertThat(tag.getVerification().isVerified(), is(false));
assertThat(GHVerification.Reason.UNSIGNED, equalTo(tag.getVerification().getReason()));
assertThat(tag.getUrl(),
containsString("/repos/hub4j-test-org/github-api/git/tags/e7aa6d4afbaa48669f0bbe11ca3c4d787b2b153c"));
assertThat(tag.getOwner().getId(), equalTo(repo.getId()));
assertThat(tag.getTagger().getEmail(), equalTo("martin.vanzijl@gmail.com"));
// Make a reference to the newly created tag.
GHRef ref = repo.createRef("refs/tags/" + tagName, tag.getSha());
assertThat(ref, notNullValue());
}
/**
* Gets the repository.
*
* @return the repository
* @throws IOException
* Signals that an I/O exception has occurred.
*/
protected GHRepository getRepository() throws IOException {
return getRepository(gitHub);
}
private GHRepository getRepository(GitHub gitHub) throws IOException {
return gitHub.getOrganization("hub4j-test-org").getRepository("github-api");
}
}