use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class MetadataModuleTest method testRestoreAuthor.
@Test
public void testRestoreAuthor() throws Exception {
Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "metadata.restore_author()");
origin.setAuthor(new Author("remove me", "remove@me.com")).addSimpleChange(0, "A change\n\nORIGINAL_AUTHOR=restore me <restore@me.com>\n");
wf.run(workdir, ImmutableList.of());
ProcessedChange change = Iterables.getLast(destination.processed);
assertThat(change.getChangesSummary()).doesNotContain("restore@me.com");
assertThat(change.getChangesSummary()).doesNotContain("ORIGINAL_AUTHOR");
assertThat(change.getAuthor().toString()).isEqualTo("restore me <restore@me.com>");
}
use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class WorkflowTest method iterativeOnlyRunForMatchingOriginFiles.
@Test
public void iterativeOnlyRunForMatchingOriginFiles() throws Exception {
origin.singleFileChange(0, "base", "file.txt", "a");
origin.singleFileChange(1, "one", "file.txt", "b");
origin.singleFileChange(2, "two", "excluded/two", "b");
origin.singleFileChange(3, "three", "copy.bara.sky", "");
origin.singleFileChange(4, "four", "copy.bara.sky", "");
transformations = ImmutableList.of();
Workflow workflow = iterativeWorkflow(/*previousRef=*/
"0");
workflow.run(workdir, /*sourceRef=*/
HEAD);
for (ProcessedChange change : destination.processed) {
System.err.println(change.getChangesSummary());
}
assertThat(destination.processed.get(0).getChangesSummary()).contains("one");
assertThat(destination.processed.get(1).getChangesSummary()).contains("three");
}
use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class WorkflowTest method testMessageTransformerForIterativeWithMigrated.
@Test
public void testMessageTransformerForIterativeWithMigrated() throws Exception {
runWorkflowForMessageTransform(WorkflowMode.ITERATIVE, "" + "def third(ctx):\n" + " msg = ''\n" + " for c in ctx.changes.migrated:\n" + " msg+='PREV: %s (%s) by %s\\n' % (c.message, c.ref, c.author.name)\n" + " ctx.set_message(ctx.message + '\\nPREVIOUS CHANGES:\\n' + msg)\n");
ProcessedChange secondCommit = destination.processed.get(0);
assertThat(secondCommit.getChangesSummary()).isEqualTo("" + "CHANGE: second commit (1) by Foo Bar\n" + "\n" + "BAR = foo\n" + "\n" + "PREVIOUS CHANGES:\n");
assertThat(secondCommit.getAuthor().toString()).isEqualTo("Someone <someone@somewhere.com>");
ProcessedChange thirdCommit = destination.processed.get(1);
assertThat(thirdCommit.getChangesSummary()).isEqualTo("" + "CHANGE: third commit (2) by Foo Baz\n" + "\n" + "BAR = foo\n" + "\n" + "PREVIOUS CHANGES:\n" + "PREV: second commit (1) by Foo Bar\n");
assertThat(thirdCommit.getAuthor().toString()).isEqualTo("Someone <someone@somewhere.com>");
}
use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class WorkflowTest method testDisableCheckout.
@Test
public void testDisableCheckout() throws Exception {
transformations = ImmutableList.of();
extraWorkflowFields = ImmutableList.of("checkout = False");
Workflow<?, ?> workflow = workflow();
DummyRevision head = origin.resolve("HEAD");
workflow.run(workdir, ImmutableList.of("HEAD"));
ProcessedChange change = Iterables.getLast(destination.processed);
assertThat(change.getOriginRef()).isEqualTo(head);
assertThatPath(workdir).containsNoMoreFiles();
}
use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class WorkflowTest method changeRequest_sot_old_baseline.
@Test
public void changeRequest_sot_old_baseline() throws Exception {
options.workflowOptions.changeRequestFromSotLimit = 2;
origin.addSimpleChange(0, "Base Change").addSimpleChange(1, "First Change").addSimpleChange(2, "Second Change").addSimpleChange(3, "Third Change");
Workflow<?, ?> workflow = iterativeWorkflow("0");
workflow.run(workdir, ImmutableList.of("1"));
ProcessedChange change = destination.processed.get(0);
assertThat(change.getBaseline()).isNull();
assertThat(change.getChangesSummary()).isEqualTo("First Change");
Workflow<?, ?> w = skylarkWorkflow("default", WorkflowMode.CHANGE_REQUEST_FROM_SOT);
w.run(workdir, ImmutableList.of("3"));
change = destination.processed.get(destination.processed.size() - 1);
assertThat(change.getChangesSummary()).isEqualTo("Third Change");
assertThat(change.getBaseline()).isEqualTo("1");
}
Aggregations