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