Search in sources :

Example 1 with ProcessedChange

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

the class WorkflowTest method excludeOriginPathIterative.

@Test
public void excludeOriginPathIterative() throws Exception {
    originFiles = "glob(['**'], exclude = ['folder/**/*.java'])";
    transformations = ImmutableList.of();
    prepareOriginExcludes("a");
    Workflow<?, ?> workflow = iterativeWorkflow(resolveHead());
    prepareOriginExcludes("b");
    prepareOriginExcludes("c");
    prepareOriginExcludes("d");
    workflow.run(workdir, ImmutableList.of(HEAD));
    for (ProcessedChange processedChange : destination.processed) {
        for (String path : ImmutableList.of("folder/file.txt", "folder2/file.txt", "folder2/subfolder/file.java", "folder/subfolder/file.txt")) {
            assertThat(processedChange.filePresent(path)).isTrue();
        }
        assertThat(processedChange.filePresent("folder/subfolder/file.java")).isFalse();
    }
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Test(org.junit.Test)

Example 2 with ProcessedChange

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

the class WorkflowTest method testForcedChangeMessageAndAuthorFlags_squash.

@Test
public void testForcedChangeMessageAndAuthorFlags_squash() throws Exception {
    options.workflowOptions.forcedChangeMessage = FORCED_MESSAGE;
    options.workflowOptions.forcedAuthor = FORCED_AUTHOR;
    origin.addSimpleChange(/*timestamp*/
    1);
    options.workflowOptions.lastRevision = resolveHead();
    origin.addSimpleChange(/*timestamp*/
    2);
    origin.addSimpleChange(/*timestamp*/
    3);
    Workflow<?, ?> workflow = workflow();
    workflow.run(workdir, ImmutableList.of(HEAD));
    assertThat(destination.processed).hasSize(1);
    ProcessedChange change = Iterables.getOnlyElement(destination.processed);
    assertThat(change.getChangesSummary()).isEqualTo(FORCED_MESSAGE);
    assertThat(change.getAuthor()).isEqualTo(FORCED_AUTHOR);
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Test(org.junit.Test)

Example 3 with ProcessedChange

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

the class WorkflowTest method usesDefaultAuthorForSquash.

@Test
public void usesDefaultAuthorForSquash() throws Exception {
    // Squash always sets the default author for the commit but not in the release notes
    origin.addSimpleChange(/*timestamp*/
    1);
    options.workflowOptions.lastRevision = resolveHead();
    origin.addSimpleChange(/*timestamp*/
    2);
    origin.addSimpleChange(/*timestamp*/
    3);
    includeReleaseNotes = true;
    Workflow<?, ?> workflow = workflow();
    workflow.run(workdir, ImmutableList.of(HEAD));
    assertThat(destination.processed).hasSize(1);
    ProcessedChange change = Iterables.getOnlyElement(destination.processed);
    assertThat(change.getChangesSummary()).contains(DEFAULT_AUTHOR.toString());
    assertThat(change.getAuthor()).isEqualTo(DEFAULT_AUTHOR);
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Test(org.junit.Test)

Example 4 with ProcessedChange

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

the class WorkflowTest method contextReferenceAsLabel.

@Test
public void contextReferenceAsLabel() throws Exception {
    origin.addSimpleChange(/*timestamp*/
    1);
    transformations = ImmutableList.of("metadata.add_header('Import of ${" + COPYBARA_CONTEXT_REFERENCE_LABEL + "}\\n')", "metadata.expose_label('" + COPYBARA_CONTEXT_REFERENCE_LABEL + "')");
    Workflow<?, ?> workflow = workflow();
    workflow.run(workdir, ImmutableList.of("HEAD"));
    ProcessedChange change = Iterables.getOnlyElement(destination.processed);
    assertThat(change.getChangesSummary()).isEqualTo("" + "Import of HEAD\n" + "\n" + "Project import generated by Copybara.\n" + "\n" + "COPYBARA_CONTEXT_REFERENCE=HEAD\n");
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) Test(org.junit.Test)

Example 5 with ProcessedChange

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

the class WorkflowTest method iterativeWorkflowWithSameOriginContext.

@Test
public void iterativeWorkflowWithSameOriginContext() throws Exception {
    for (int timestamp = 0; timestamp < 10; timestamp++) {
        origin.addSimpleChangeWithContextReference(timestamp, "HEAD");
    }
    Workflow<?, ?> workflow = iterativeWorkflow("0");
    // First change is migrated without context reference. Then we run again with
    // context ("HEAD").
    workflow.run(workdir, ImmutableList.of("1"));
    workflow = iterativeWorkflow(/*previousRef=*/
    null);
    workflow.run(workdir, ImmutableList.of("HEAD"));
    Set<String> identities = new HashSet<>();
    for (ProcessedChange change : destination.processed) {
        identities.add(change.getChangeIdentity());
    }
    // All change identities are different
    assertThat(identities).hasSize(destination.processed.size());
}
Also used : ProcessedChange(com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange) HashSet(java.util.HashSet) 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