Search in sources :

Example 16 with ProcessedChange

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

the class MetadataModuleTest method testRestoreAuthorOtherLabelAndSeparator.

@Test
public void testRestoreAuthorOtherLabelAndSeparator() throws Exception {
    Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "metadata.restore_author('OTHER_LABEL', separator=': ')");
    origin.setAuthor(new Author("remove me", "remove@me.com")).addSimpleChange(0, "A change\n\n" + "OTHER_LABEL: restore me <restore@me.com>\n" + "ORIGINAL_AUTHOR=no no <no@no.com>\n");
    wf.run(workdir, ImmutableList.of());
    ProcessedChange change = Iterables.getLast(destination.processed);
    assertThat(change.getChangesSummary()).doesNotContain("restore@me.com");
    assertThat(change.getChangesSummary()).contains("ORIGINAL_AUTHOR=no no <no@no.com>");
    assertThat(change.getChangesSummary()).doesNotContain("OTHER_LABEL:");
    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 17 with ProcessedChange

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

the class MetadataModuleTest method testSaveAuthorOtherLabelAndSeparator.

@Test
public void testSaveAuthorOtherLabelAndSeparator() throws Exception {
    Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "metadata.save_author('OTHER_LABEL', separator=': ')");
    origin.setAuthor(new Author("keep me", "keep@me.com")).addSimpleChange(0, "A change");
    wf.run(workdir, ImmutableList.of());
    ProcessedChange change = Iterables.getLast(destination.processed);
    assertThat(change.getChangesSummary()).contains("OTHER_LABEL: keep me <keep@me.com>");
    assertThat(change.getChangesSummary()).doesNotContain("ORIGINAL_AUTHOR");
    assertThat(change.getChangesSummary()).doesNotContain("ORIGINAL_AUTHOR=");
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Author(com.google.copybara.authoring.Author) Test(org.junit.Test)

Example 18 with ProcessedChange

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

the class MetadataModuleTest method testRestoreAuthorOtherSeparator.

@Test
public void testRestoreAuthorOtherSeparator() throws Exception {
    Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "metadata.restore_author(separator=': ')");
    origin.setAuthor(new Author("remove me", "remove@me.com")).addSimpleChange(0, "A change\n\n" + "ORIGINAL_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 19 with ProcessedChange

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

the class MetadataModuleTest method testReplaceMessage.

@Test
public void testReplaceMessage() throws Exception {
    options.setLastRevision(origin.resolve("HEAD").asString());
    Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "metadata.replace_message('[HEADER with ${LABEL}]\\n')");
    origin.addSimpleChange(0, "" + "A change\n" + "\n" + "LABEL=some label\n");
    wf.run(workdir, ImmutableList.of());
    ProcessedChange change = Iterables.getLast(destination.processed);
    assertThat(change.getChangesSummary()).isEqualTo("[HEADER with some label]\n");
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Test(org.junit.Test)

Example 20 with ProcessedChange

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

the class MetadataModuleTest method testMessageTransformerForSquashExtendedNoDescription.

@Test
public void testMessageTransformerForSquashExtendedNoDescription() throws Exception {
    runWorkflow(WorkflowMode.SQUASH, "" + "metadata.squash_notes(" + "  prefix = 'Importing foo project:\\n'," + "  show_description = False," + "  compact = False\n" + ")");
    ProcessedChange change = Iterables.getOnlyElement(destination.processed);
    assertThat(change.getChangesSummary()).isEqualTo("" + "Importing foo project:\n" + "--\n" + "2 by Foo Baz <foo@baz.com>\n" + "--\n" + "1 by Foo Bar <foo@bar.com>\n");
    assertThat(change.getAuthor()).isEqualTo(DEFAULT_AUTHOR);
}
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