use of com.google.copybara.exception.ValidationException in project copybara by google.
the class WorkflowTest method testShowDiffInOriginFail.
@Test
public void testShowDiffInOriginFail() throws Exception {
origin.addSimpleChange(/*timestamp*/
1);
origin.addSimpleChange(/*timestamp*/
2);
origin.addSimpleChange(/*timestamp*/
3);
options.workflowOptions.lastRevision = "1";
options.workflowOptions.diffInOrigin = true;
Workflow<?, ?> workflow = (Workflow<?, ?>) new SkylarkTestExecutor(options).loadConfig("core.workflow(\n" + " name = 'foo',\n" + " origin = testing.origin(),\n" + " destination = testing.destination(),\n" + " mode = 'ITERATIVE',\n" + " authoring = " + authoring + ",\n" + " transformations = [metadata.replace_message(''),],\n" + ")\n").getMigration("foo");
ValidationException e = assertThrows(ValidationException.class, () -> workflow.run(workdir, ImmutableList.of("HEAD")));
assertThat(e).hasMessageThat().contains("diff_in_origin is not supported by origin " + origin.getType());
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class WorkflowTest method smartPruneForDifferentWorkflowMode.
@Test
public void smartPruneForDifferentWorkflowMode() throws Exception {
smartPrune = true;
ValidationException e = assertThrows(ValidationException.class, () -> skylarkWorkflow("default", WorkflowMode.SQUASH));
console().assertThat().onceInLog(MessageType.ERROR, ".*'smart_prune = True' is only supported for CHANGE_REQUEST mode.*");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class WorkflowTest method changeRequestWithFolderDestinationError.
@Test
public void changeRequestWithFolderDestinationError() throws IOException, ValidationException, RepoException {
origin.singleFileChange(/*timestamp=*/
44, "commit 1", "bar.txt", "1");
ValidationException thrown = assertThrows(ValidationException.class, () -> loadConfig("core.workflow(\n" + " name = 'foo',\n" + " origin = testing.origin(),\n" + " destination = folder.destination(),\n" + " authoring = " + authoring + ",\n" + " mode = 'CHANGE_REQUEST',\n" + ")\n").getMigration("foo").run(workdir, ImmutableList.of()));
assertThat(thrown).hasMessageThat().contains("'CHANGE_REQUEST' is incompatible with destinations that don't support" + " history");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class WorkflowTest method invalidExcludedOriginPath.
@Test
public void invalidExcludedOriginPath() throws Exception {
prepareOriginExcludes("a");
String outsideFolder = "../../file";
Path file = workdir.resolve(outsideFolder);
Files.createDirectories(file.getParent());
Files.write(file, new byte[] {});
originFiles = "glob(['" + outsideFolder + "'])";
ValidationException e = assertThrows(ValidationException.class, () -> workflow().run(workdir, ImmutableList.of(HEAD)));
console().assertThat().onceInLog(MessageType.ERROR, "(\n|.)*path has unexpected [.] or [.][.] components(\n|.)*");
assertThatPath(workdir).containsFiles(outsideFolder);
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class WorkflowTest method changeRequest_customRevIdLabelWithSetRevId.
@Test
public void changeRequest_customRevIdLabelWithSetRevId() throws Exception {
extraWorkflowFields = ImmutableList.of("experimental_custom_rev_id = \"CUSTOM_REV_ID\"");
setRevId = true;
ValidationException e = assertThrows(ValidationException.class, () -> changeRequestWorkflow(null));
assertThat(e.getMessage()).containsMatch("experimental_custom_rev_id is not allowed to be used in CHANGE_REQUEST mode if " + "set_rev_id is set to true. experimental_custom_rev_id is used");
}
Aggregations