Search in sources :

Example 31 with ProcessedChange

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

Example 32 with ProcessedChange

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

Example 33 with ProcessedChange

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

Example 34 with ProcessedChange

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

Example 35 with ProcessedChange

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");
}
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