use of com.google.copybara.testing.DummyRevision in project copybara by google.
the class GerritDestinationTest method specifyChangeId.
@Test
public void specifyChangeId() throws Exception {
fetch = "master";
writeFile(workdir, "file", "some content");
String changeId = "Iaaaaaaaaaabbbbbbbbbbccccccccccdddddddddd";
options.setForce(true);
options.gerrit.gerritChangeId = changeId;
process(new DummyRevision("origin_ref"));
assertThat(lastCommitChangeIdLine("origin_ref", repo())).isEqualTo(GerritDestination.CHANGE_ID_LABEL + ": " + changeId);
git("branch", "master", getGerritRef(repo(), "refs/for/master"));
writeFile(workdir, "file", "some different content");
changeId = "Ibbbbbbbbbbccccccccccddddddddddeeeeeeeeee";
options.setForce(false);
options.gerrit.gerritChangeId = changeId;
process(new DummyRevision("origin_ref"));
assertThat(lastCommitChangeIdLine("origin_ref", repo())).isEqualTo(GerritDestination.CHANGE_ID_LABEL + ": " + changeId);
}
use of com.google.copybara.testing.DummyRevision in project copybara by google.
the class GerritDestinationTest method testCc.
@Test
public void testCc() throws Exception {
pushToRefsFor = "master";
writeFile(workdir, "file", "some content");
fetch = "master";
options.gerrit.gerritTopic = "testTopic";
options.setForce(true);
url = "https://localhost:33333/foo/bar";
mockNoChangesFound();
DummyRevision originRef = new DummyRevision("origin_ref");
GerritDestination destination = destination("submit = False", "cc = [\"${SOME_REVIEWER}\"]");
Glob glob = Glob.createGlob(ImmutableList.of("**"), excludedDestinationPaths);
WriterContext writerContext = new WriterContext("GerritDestination", "TEST", false, new DummyRevision("test"), Glob.ALL_FILES.roots());
List<DestinationEffect> result = destination.newWriter(writerContext).write(TransformResults.of(workdir, originRef).withSummary("Test message").withIdentity(originRef.asString()).withLabelFinder(e -> e.equals("SOME_REVIEWER") ? ImmutableList.of("foo@example.com") : ImmutableList.of()), glob, console);
assertThat(result).hasSize(1);
assertThat(result.get(0).getErrors()).isEmpty();
assertPushRef("refs/for/master%topic=testTopic,hashtag=copybara_id_origin_ref_commiter@email," + "cc=foo@example.com");
}
use of com.google.copybara.testing.DummyRevision in project copybara by google.
the class GerritDestinationTest method testHashTagFound.
@Test
public void testHashTagFound() throws Exception {
fetch = "master";
writeFile(workdir, "file", "some content");
options.setForce(true);
String secondChangeId = "I" + Hashing.sha1().newHasher().putString("origin_ref", StandardCharsets.UTF_8).putString(options.gitDestination.committerEmail, StandardCharsets.UTF_8).putInt(1).hash();
gitUtil.mockApi(eq("GET"), eq("https://localhost:33333/changes/?q=" + "hashtag:%22copybara_id_origin_ref_commiter@email%22%20AND" + "%20project:foo/bar%20AND%20status:NEW"), mockResponse(String.format("[{ change_id : \"%s\", status : \"NEW\"}]", secondChangeId)));
process(new DummyRevision("origin_ref"));
assertThat(lastCommitChangeIdLine("origin_ref", repo())).isEqualTo(GerritDestination.CHANGE_ID_LABEL + ": " + secondChangeId);
}
use of com.google.copybara.testing.DummyRevision in project copybara by google.
the class GerritDestinationTest method changeExists.
@Test
public void changeExists() throws Exception {
fetch = "master";
writeFile(workdir, "file", "some content");
options.setForce(true);
process(new DummyRevision("origin_ref"));
// ChangeId is randomly generated.
assertThat(lastCommitChangeIdLine("origin_ref", repo())).isNotEmpty();
}
use of com.google.copybara.testing.DummyRevision in project copybara by google.
the class GerritDestinationTest method testLabels.
@Test
public void testLabels() throws Exception {
pushToRefsFor = "master";
writeFile(workdir, "file", "some content");
fetch = "master";
options.gerrit.gerritTopic = "testTopic";
options.setForce(true);
url = "https://localhost:33333/foo/bar";
mockNoChangesFound();
DummyRevision originRef = new DummyRevision("origin_ref");
GerritDestination destination = destination("submit = False", "labels = [\"${SOME_LABELS}\"]");
Glob glob = Glob.createGlob(ImmutableList.of("**"), excludedDestinationPaths);
WriterContext writerContext = new WriterContext("GerritDestination", "TEST", false, new DummyRevision("test"), Glob.ALL_FILES.roots());
List<DestinationEffect> result = destination.newWriter(writerContext).write(TransformResults.of(workdir, originRef).withSummary("Test message").withIdentity(originRef.asString()).withLabelFinder(e -> e.equals("SOME_LABELS") ? ImmutableList.of("Foo+1", "Bar-1") : ImmutableList.of()), glob, console);
assertThat(result).hasSize(1);
assertThat(result.get(0).getErrors()).isEmpty();
assertPushRef("refs/for/master%topic=testTopic,hashtag=copybara_id_origin_ref_commiter@email," + "label=Foo\\+1,label=Bar-1");
}
Aggregations