use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class WorkflowTest method changeRequest_defaultAuthoring.
@Test
public void changeRequest_defaultAuthoring() throws Exception {
origin.addSimpleChange(0, "One Change\n" + destination.getLabelNameWhenOrigin() + "=42").addSimpleChange(1, "Second Change");
Workflow<?, ?> workflow = changeRequestWorkflow(null);
workflow.run(workdir, ImmutableList.of("1"));
ProcessedChange change = destination.processed.get(0);
assertThat(change.getBaseline()).isEqualTo("42");
assertThat(change.getAuthor()).isEqualTo(DEFAULT_AUTHOR);
console().assertThat().onceInLog(MessageType.PROGRESS, ".*Checking that the transformations can be reverted");
}
use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class WorkflowTest method testDateTimeOffset.
@Test
public void testDateTimeOffset() throws Exception {
runWorkflowForMessageTransform(WorkflowMode.ITERATIVE, "" + "def third(ctx):\n" + " msg = ''\n" + " for c in ctx.changes.current:\n" + " msg += c.date_time_iso_offset + '\\n'\n" + " ctx.set_message(msg)\n");
ProcessedChange change = destination.processed.get(1);
TemporalAccessor actual = DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(change.getChangesSummary().trim());
// Refers to the same time
assertThat(actual.getLong(ChronoField.INSTANT_SECONDS)).isEqualTo(change.getTimestamp().getLong(ChronoField.INSTANT_SECONDS));
// With the same time-zone
assertThat(actual.getLong(ChronoField.OFFSET_SECONDS)).isEqualTo(change.getTimestamp().getLong(ChronoField.OFFSET_SECONDS));
}
use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class WorkflowTest method emptyTransformList.
@Test
public void emptyTransformList() throws Exception {
origin.addSimpleChange(/*timestamp*/
1);
transformations = ImmutableList.of();
Workflow<?, ?> workflow = workflow();
workflow.run(workdir, ImmutableList.of("0"));
ProcessedChange change = Iterables.getOnlyElement(destination.processed);
assertThat(change.getContent("file.txt")).isEqualTo("0");
}
use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class WorkflowTest method testMessageTransformerForSquash.
@Test
public void testMessageTransformerForSquash() throws Exception {
runWorkflowForMessageTransform(SQUASH, /*thirdTransform=*/
null);
ProcessedChange change = Iterables.getOnlyElement(destination.processed);
assertThat(change.getChangesSummary()).isEqualTo("" + "CHANGE: third commit (2) by Foo Baz\n" + "CHANGE: second commit (1) by Foo Bar\n" + "\n" + "BAR = foo\n");
assertThat(change.getAuthor().toString()).isEqualTo("Someone <someone@somewhere.com>");
}
use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class WorkflowTest method testSquashFlagOverridesIterative.
@Test
public void testSquashFlagOverridesIterative() 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();
// Run with --squash
options.general.squash = true;
Workflow<?, ?> workflow = iterativeWorkflow(/*previousRef=*/
"0");
workflow.run(workdir, ImmutableList.of("2"));
assertThat(destination.processed).hasSize(1);
ProcessedChange change = Iterables.getOnlyElement(destination.processed);
assertThat(change.getChangesSummary()).contains("Project import generated by Copybara.\n");
// Regular run afterwards
workflow = iterativeWorkflow(/*previousRef=*/
null);
options.general.squash = false;
workflow.run(workdir, ImmutableList.of(HEAD));
assertThat(destination.processed).hasSize(2);
}
Aggregations