Search in sources :

Example 21 with ProcessedChange

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

the class MetadataModuleTest method testsSaveAuthorOtherLabel.

@Test
public void testsSaveAuthorOtherLabel() throws Exception {
    Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "metadata.save_author('OTHER_LABEL')");
    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");
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Author(com.google.copybara.authoring.Author) Test(org.junit.Test)

Example 22 with ProcessedChange

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

the class MetadataModuleTest method checkScrubber.

private void checkScrubber(String commitMsg, String scrubber, String expectedMsg) throws IOException, ValidationException, RepoException {
    Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, scrubber);
    origin.addSimpleChange(0, commitMsg);
    wf.run(workdir, ImmutableList.of());
    ProcessedChange change = Iterables.getLast(destination.processed);
    assertThat(change.getChangesSummary()).isEqualTo(expectedMsg);
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange)

Example 23 with ProcessedChange

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

the class MetadataModuleTest method testsSaveReplaceAuthor.

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

Example 24 with ProcessedChange

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

the class MetadataModuleTest method testSaveAuthorOtherSeparator.

@Test
public void testSaveAuthorOtherSeparator() throws Exception {
    Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "metadata.save_author(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("ORIGINAL_AUTHOR: keep me <keep@me.com>");
    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 25 with ProcessedChange

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

the class MetadataModuleTest method testMessageTransformerForSquashReverse.

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