Search in sources :

Example 6 with ProcessedChange

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");
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Test(org.junit.Test)

Example 7 with ProcessedChange

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));
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) TemporalAccessor(java.time.temporal.TemporalAccessor) Test(org.junit.Test)

Example 8 with ProcessedChange

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");
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Test(org.junit.Test)

Example 9 with ProcessedChange

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>");
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Test(org.junit.Test)

Example 10 with ProcessedChange

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);
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Test(org.junit.Test)

Aggregations

ProcessedChange (com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange)59 Test (org.junit.Test)57 Author (com.google.copybara.authoring.Author)11 Revision (com.google.copybara.Revision)4 Workflow (com.google.copybara.Workflow)4 RecordsProcessCallDestination (com.google.copybara.testing.RecordsProcessCallDestination)4 ValidationException (com.google.copybara.exception.ValidationException)2 DummyRevision (com.google.copybara.testing.DummyRevision)2 TemporalAccessor (java.time.temporal.TemporalAccessor)1 HashSet (java.util.HashSet)1