Search in sources :

Example 36 with ProcessedChange

use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.

the class WorkflowTest method changeRequestWorkflowTestRecordContextReference.

@Test
public void changeRequestWorkflowTestRecordContextReference() throws Exception {
    origin.addSimpleChange(0, "One Change\n" + destination.getLabelNameWhenOrigin() + "=42").addSimpleChange(1, "Second Change");
    Workflow<?, ?> workflow = changeRequestWorkflow(null);
    workflow.run(workdir, ImmutableList.of("HEAD"));
    ProcessedChange change = destination.processed.get(0);
    assertThat(change.getBaseline()).isEqualTo("42");
    assertThat(change.getRequestedRevision().contextReference()).isEqualTo("HEAD");
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Test(org.junit.Test)

Example 37 with ProcessedChange

use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.

the class WorkflowTest method squashWorkflowTestRecordContextReference.

@Test
public void squashWorkflowTestRecordContextReference() throws Exception {
    origin.addSimpleChange(/*timestamp*/
    1);
    transformations = ImmutableList.of();
    Workflow<?, ?> workflow = workflow();
    workflow.run(workdir, ImmutableList.of("HEAD"));
    ProcessedChange change = Iterables.getOnlyElement(destination.processed);
    assertThat(change.getRequestedRevision().contextReference()).isEqualTo("HEAD");
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Test(org.junit.Test)

Example 38 with ProcessedChange

use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.

the class WorkflowTest method iterativeWorkflowTestRecordMigrationKey.

@Test
public void iterativeWorkflowTestRecordMigrationKey() throws Exception {
    for (int timestamp = 0; timestamp < 10; timestamp++) {
        origin.addSimpleChange(timestamp);
    }
    String name = "notDefaultWorkflow";
    Workflow<?, ?> workflow = iterativeWorkflow(name, "0");
    workflow.run(workdir, ImmutableList.of("1"));
    workflow = iterativeWorkflow(name, null);
    workflow.run(workdir, ImmutableList.of("HEAD"));
    for (ProcessedChange change : destination.processed) {
        assertThat(change.getWorkflowName()).isEqualTo(name);
    }
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Test(org.junit.Test)

Example 39 with ProcessedChange

use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.

the class WorkflowTest method testMessageTransformerForIterative.

@Test
public void testMessageTransformerForIterative() throws Exception {
    runWorkflowForMessageTransform(WorkflowMode.ITERATIVE, /*thirdTransform=*/
    null);
    ProcessedChange secondCommit = destination.processed.get(0);
    assertThat(secondCommit.getChangesSummary()).isEqualTo("" + "CHANGE: second commit (1) by Foo Bar\n" + "\n" + "BAR = foo\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");
    assertThat(thirdCommit.getAuthor().toString()).isEqualTo("Someone <someone@somewhere.com>");
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Test(org.junit.Test)

Example 40 with ProcessedChange

use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.

the class WorkflowTest method changeRequest_sot.

@Test
public void changeRequest_sot() throws Exception {
    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("HEAD"));
    ProcessedChange change = destination.processed.get(2);
    assertThat(change.getBaseline()).isNull();
    assertThat(change.getChangesSummary()).isEqualTo("Third Change");
    Workflow<?, ?> w = skylarkWorkflow("default", WorkflowMode.CHANGE_REQUEST_FROM_SOT);
    w.run(workdir, ImmutableList.of("2"));
    change = destination.processed.get(destination.processed.size() - 1);
    assertThat(change.getChangesSummary()).isEqualTo("Second Change");
    assertThat(change.getBaseline()).isEqualTo("1");
}
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