use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class WorkflowTest method testMessageTransformerForChangeRequest.
@Test
public void testMessageTransformerForChangeRequest() throws Exception {
options.workflowOptions.changeBaseline = "1";
runWorkflowForMessageTransform(WorkflowMode.CHANGE_REQUEST, /*thirdTransform=*/
null);
ProcessedChange change = Iterables.getOnlyElement(destination.processed);
assertThat(change.getChangesSummary()).isEqualTo("" + "CHANGE: third commit (2) by Foo Baz\n" + "\n" + "BAR = foo\n");
assertThat(change.getAuthor().toString()).isEqualTo("Someone <someone@somewhere.com>");
}
use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class WorkflowTest method iterativeWorkflowTestRecordContextReference.
@Test
public void iterativeWorkflowTestRecordContextReference() throws Exception {
for (int timestamp = 0; timestamp < 10; timestamp++) {
origin.addSimpleChange(timestamp);
}
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"));
for (ProcessedChange change : destination.processed) {
assertThat(change.getRequestedRevision().contextReference()).isEqualTo(change.getOriginRef().asString().equals("1") ? null : "HEAD");
}
}
use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class WorkflowTest method checkChangeRequest_sot_ahead_sot.
private void checkChangeRequest_sot_ahead_sot() throws IOException, ValidationException, RepoException {
options.workflowOptions.changeRequestFromSotLimit = 1;
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);
try {
w.run(workdir, ImmutableList.of("3"));
fail();
} catch (ValidationException e) {
assertThat(e).hasMessageThat().contains("Make sure to sync the submitted changes");
}
}
use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class WorkflowTest method iterativeWorkflowTest_defaultAuthoring.
@Test
public void iterativeWorkflowTest_defaultAuthoring() throws Exception {
for (int timestamp = 0; timestamp < 61; timestamp++) {
origin.addSimpleChange(timestamp);
}
Workflow<?, ?> workflow = iterativeWorkflow(/*previousRef=*/
"42");
workflow.run(workdir, ImmutableList.of("50"));
assertThat(destination.processed).hasSize(8);
int nextChange = 43;
for (ProcessedChange change : destination.processed) {
assertThat(change.getChangesSummary()).isEqualTo(nextChange + " change");
String asString = Integer.toString(nextChange);
assertThat(change.getOriginRef().asString()).isEqualTo(asString);
assertThat(change.numFiles()).isEqualTo(1);
assertThat(change.getContent("file.txt")).isEqualTo(PREFIX + asString);
assertThat(change.getAuthor()).isEqualTo(DEFAULT_AUTHOR);
nextChange++;
}
workflow = iterativeWorkflow(null);
workflow.run(workdir, ImmutableList.of("60"));
assertThat(destination.processed).hasSize(18);
}
use of com.google.copybara.testing.RecordsProcessCallDestination.ProcessedChange in project copybara by google.
the class WorkflowTest method changeRequest_sot_no_origin_files_match.
@Test
public void changeRequest_sot_no_origin_files_match() throws Exception {
options.workflowOptions.changeRequestFromSotLimit = 1;
origin.addSimpleChange(0, "Base Change").addSimpleChange(1, "First Change").addSimpleChange(2, "Second 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");
origin.singleFileChange(3, "pending", "I_dont_exist/file.txt", "content");
originFiles = "glob(['I_dont_exist/**'])";
Workflow<?, ?> w = skylarkWorkflow("default", WorkflowMode.CHANGE_REQUEST_FROM_SOT);
ValidationException e = assertThrows(ValidationException.class, () -> w.run(workdir, ImmutableList.of("3")));
assertThat(e).hasMessageThat().contains("Couldn't find any parent change for 3" + " and origin_files = glob(include = [\"I_dont_exist/**\"])");
}
Aggregations