Merge branch 'master' into sign_verification

This commit is contained in:
Liam Newman
2020-03-26 10:23:16 -07:00
committed by GitHub
26 changed files with 843 additions and 260 deletions

View File

@@ -10,6 +10,7 @@ import org.junit.Test;
import org.kohsuke.github.GHCommit.File;
import org.kohsuke.github.GHOrganization.Permission;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -795,7 +796,7 @@ public class AppTest extends AbstractGitHubWireMockTest {
GHRepository r = gitHub.getRepository("github-api-test-org/test-labels");
List<GHLabel> lst = r.listLabels().toList();
for (GHLabel l : lst) {
// System.out.println(l.getName());
assertThat(l.getUrl(), containsString(l.getName().replace(" ", "%20")));
}
assertTrue(lst.size() > 5);
GHLabel e = r.getLabel("enhancement");
@@ -805,9 +806,13 @@ public class AppTest extends AbstractGitHubWireMockTest {
GHLabel t = null;
GHLabel t2 = null;
GHLabel t3 = null;
try {// CRUD
t = r.createLabel("test", "123456");
t2 = r.getLabel("test");
assertThat(t, not(sameInstance(t2)));
assertThat(t, equalTo(t2));
assertEquals(t.getName(), t2.getName());
assertEquals(t.getColor(), "123456");
assertEquals(t.getColor(), t2.getColor());
@@ -815,28 +820,69 @@ public class AppTest extends AbstractGitHubWireMockTest {
assertEquals(t.getDescription(), t2.getDescription());
assertEquals(t.getUrl(), t2.getUrl());
t.setColor("000000");
// update works on multiple changes in one call
t3 = t.update().color("000000").description("It is dark!").done();
// instances behave as immutable by default. Update returns a new updated instance.
assertThat(t, not(sameInstance(t2)));
assertThat(t, equalTo(t2));
assertThat(t, not(sameInstance(t3)));
assertThat(t, not(equalTo(t3)));
// This is annoying behavior, but it is by design at this time.
// Verifying so we can know when it is fixed.
assertEquals(t.getColor(), "123456");
assertEquals(t.getDescription(), "");
assertEquals(t3.getColor(), "000000");
assertEquals(t3.getDescription(), "It is dark!");
// Test deprecated methods
t.setDescription("Deprecated");
t = r.getLabel("test");
t.setDescription("this is also a test");
GHLabel t3 = r.getLabel("test");
// By using the old instance t when calling setDescription it also sets color to the old value
// this is a bad behavior, but it is expected
assertEquals(t.getColor(), "123456");
assertEquals(t.getDescription(), "Deprecated");
t.setColor("000000");
t = r.getLabel("test");
assertEquals(t.getColor(), "000000");
assertEquals(t.getDescription(), "Deprecated");
// set() makes a single change
t3 = t.set().description("this is also a test");
// instances behave as immutable by default. Update returns a new updated instance.
assertThat(t, not(sameInstance(t3)));
assertThat(t, not(equalTo(t3)));
assertEquals(t3.getColor(), "000000");
assertEquals(t3.getDescription(), "this is also a test");
t.delete();
try {
t = r.getLabel("test");
fail("Test label should be deleted.");
} catch (IOException ex) {
assertThat(ex, instanceOf(FileNotFoundException.class));
}
t = r.createLabel("test2", "123457", "this is a different test");
t2 = r.getLabel("test2");
assertEquals(t.getName(), t2.getName());
assertEquals(t.getColor(), "123457");
assertEquals(t.getColor(), t2.getColor());
assertEquals(t.getDescription(), "this is a different test");
assertEquals(t.getDescription(), t2.getDescription());
assertEquals(t.getUrl(), t2.getUrl());
t.delete();
// Allow null description
t = GHLabel.create(r).name("test2").color("123458").done();
assertThat(t.getName(), equalTo("test2"));
assertThat(t.getDescription(), is(nullValue()));
} finally {
cleanupLabel("test");
cleanupLabel("test2");
@@ -846,7 +892,7 @@ public class AppTest extends AbstractGitHubWireMockTest {
void cleanupLabel(String name) {
if (mockGitHub.isUseProxy()) {
try {
GHLabel t = getGitHubBeforeAfter().getRepository("github-api-test-org/test-labels").getLabel("test");
GHLabel t = getGitHubBeforeAfter().getRepository("github-api-test-org/test-labels").getLabel(name);
t.delete();
} catch (IOException e) {