use of com.google.copybara.exception.ValidationException in project copybara by google.
the class MetadataModuleTest method testScrubberWithPreconditionFailForCustomizeMsg.
@Test
public void testScrubberWithPreconditionFailForCustomizeMsg() throws Exception {
ValidationException e = assertThrows(ValidationException.class, () -> checkScrubber("this\nis\nvery confidential\nbut this is not public\nnot for public\n", "metadata.scrubber('^(?:\\n|.)*PUBLIC:((?:\\n|.)*)(?:\\n|.)*$', " + "msg_if_no_match = 'This is not confidential.'," + "fail_if_no_match = True," + "replacement = '$1')", /*not used*/
null));
assertThat(e).hasMessageThat().contains("If fail_if_no_match is true, msg_if_no_match should be None.");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class MetadataModuleTest method testMetadataVerifyNoMatchFails.
@Test
public void testMetadataVerifyNoMatchFails() throws Exception {
options.setLastRevision(origin.resolve("HEAD").asString());
Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "metadata.verify_match(\"bar\", verify_no_match = True)");
origin.addSimpleChange(0, "bar");
ValidationException e = assertThrows(ValidationException.class, () -> wf.run(workdir, ImmutableList.of("HEAD")));
assertThat(e).hasMessageThat().contains("'bar' found in the change message");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class MetadataModuleTest method testMetadataVerifyMatchFails.
@Test
public void testMetadataVerifyMatchFails() throws Exception {
Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "metadata.verify_match(\"foobar\")");
ValidationException e = assertThrows(ValidationException.class, () -> wf.run(workdir, ImmutableList.of("HEAD")));
assertThat(e).hasMessageThat().contains("Could not find 'foobar' in the change message");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class MetadataModuleTest method testAddHeaderLabelNotFound.
@Test
public void testAddHeaderLabelNotFound() throws Exception {
options.setLastRevision(origin.resolve("HEAD").asString());
Workflow<?, ?> wf = createWorkflow(WorkflowMode.ITERATIVE, "metadata.add_header('[HEADER with ${LABEL}]')");
origin.addSimpleChange(0, "foo");
ValidationException thrown = assertThrows(ValidationException.class, () -> wf.run(workdir, ImmutableList.of()));
assertThat(thrown).hasMessageThat().contains("Cannot find label 'LABEL'");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class RepositoryUtilTest method testBadUrl.
@Test
public void testBadUrl() {
ValidationException expected = assertThrows(ValidationException.class, () -> RepositoryUtil.validateNotHttp("http://copybara.com"));
assertThat(expected).hasMessageThat().contains("URL 'http://copybara.com' is not valid - should be using https");
}
Aggregations