use of com.google.copybara.exception.ChangeRejectedException in project copybara by google.
the class WorkflowTest method iterativeWorkflowConfirmationHandlingTest.
@Test
public void iterativeWorkflowConfirmationHandlingTest() throws Exception {
for (int timestamp = 0; timestamp < 10; timestamp++) {
origin.addSimpleChange(timestamp);
}
console().respondYes().respondNo();
RecordsProcessCallDestination programmableDestination = new RecordsProcessCallDestination(ImmutableList.of(ImmutableList.of(), ImmutableList.of("some error"), ImmutableList.of("Another error")));
options.testingOptions.destination = programmableDestination;
Workflow<?, ?> workflow = iterativeWorkflow(/*previousRef=*/
"2");
ChangeRejectedException expected = assertThrows(ChangeRejectedException.class, () -> workflow.run(workdir, ImmutableList.of("9")));
assertThat(expected.getMessage()).contains("Iterative workflow aborted by user after: Change 3 of 7 (5)");
assertThat(programmableDestination.processed).hasSize(3);
}
use of com.google.copybara.exception.ChangeRejectedException in project copybara by google.
the class WorkflowTest method testTestWorkflowWithDiffInOriginAndRespondNo.
@Test
public void testTestWorkflowWithDiffInOriginAndRespondNo() throws Exception {
GitRepository remote = GitRepository.newBareRepo(Files.createTempDirectory("gitdir"), getGitEnv(), /*verbose=*/
true, DEFAULT_TIMEOUT, /*noVerify=*/
false).withWorkTree(workdir);
remote.init();
String primaryBranch = remote.getPrimaryBranch();
Files.write(workdir.resolve("foo.txt"), new byte[] {});
remote.add().files("foo.txt").run();
remote.simpleCommand("commit", "foo.txt", "-m", "message_a");
GitRevision lastRev = remote.resolveReference(primaryBranch);
Files.write(workdir.resolve("bar.txt"), "change content".getBytes(UTF_8));
remote.add().files("bar.txt").run();
remote.simpleCommand("commit", "bar.txt", "-m", "message_s");
TestingConsole testingConsole = new TestingConsole().respondNo();
options.workflowOptions.lastRevision = lastRev.getSha1();
options.setWorkdirToRealTempDir().setConsole(testingConsole).setHomeDir(StandardSystemProperty.USER_HOME.value());
Workflow<?, ?> workflow = (Workflow<?, ?>) new SkylarkTestExecutor(options).loadConfig("core.workflow(\n" + " name = 'foo',\n" + " origin = git.origin(url='" + remote.getGitDir() + "'),\n" + " destination = folder.destination(),\n" + " mode = 'ITERATIVE',\n" + " authoring = " + authoring + ",\n" + " transformations = [metadata.replace_message(''),],\n" + ")\n").getMigration("foo");
workflow.getWorkflowOptions().diffInOrigin = true;
ChangeRejectedException e = assertThrows(ChangeRejectedException.class, () -> workflow.run(workdir, ImmutableList.of(primaryBranch)));
assertThat(e.getMessage()).contains("User aborted execution: did not confirm diff in origin changes.");
}
Aggregations