use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitDestinationTest method testChangeDescriptionEmpty_setRevId.
@Test
public void testChangeDescriptionEmpty_setRevId() throws Exception {
fetch = primaryBranch;
push = primaryBranch;
Path scratchTree = Files.createTempDirectory("GitDestinationTest-testLocalRepo");
Files.write(scratchTree.resolve("foo"), "foo\n".getBytes(UTF_8));
repo().withWorkTree(scratchTree).add().force().files("foo").run();
repo().withWorkTree(scratchTree).simpleCommand("commit", "-a", "-m", "change");
DummyRevision originRef = new DummyRevision("origin_ref");
WriterContext writerContext = new WriterContext("GitDestinationTest", "test", true, new DummyRevision("origin_ref1"), Glob.ALL_FILES.roots());
Writer<GitRevision> writer = destination().newWriter(writerContext);
ValidationException e = assertThrows(ValidationException.class, () -> writer.write(TransformResults.of(workdir, originRef).withSummary("").withLabelFinder(s -> ImmutableList.of()).withSetRevId(false), Glob.createGlob(ImmutableList.of("**"), ImmutableList.of("test.txt")), console));
assertThat(e).hasMessageThat().contains("Change description is empty");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitDestinationTest method testChangeDescriptionEmpty.
@Test
public void testChangeDescriptionEmpty() throws Exception {
fetch = primaryBranch;
push = primaryBranch;
Path scratchTree = Files.createTempDirectory("GitDestinationTest-testLocalRepo");
Files.write(scratchTree.resolve("foo"), "foo\n".getBytes(UTF_8));
repo().withWorkTree(scratchTree).add().force().files("foo").run();
repo().withWorkTree(scratchTree).simpleCommand("commit", "-a", "-m", "change");
DummyRevision originRef = new DummyRevision("origin_ref");
WriterContext writerContext = new WriterContext("GitDestinationTest", "test", true, new DummyRevision("origin_ref1"), Glob.ALL_FILES.roots());
Writer<GitRevision> writer = destination().newWriter(writerContext);
ValidationException e = assertThrows(ValidationException.class, () -> writer.write(TransformResults.of(workdir, originRef).withSummary(" "), Glob.createGlob(ImmutableList.of("**"), ImmutableList.of("test.txt")), console));
assertThat(e).hasMessageThat().contains("Change description is empty");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitHubPrDestinationTest method testFindProject.
@Test
public void testFindProject() throws ValidationException {
checkFindProject("https://github.com/foo", "foo");
checkFindProject("https://github.com/foo/bar", "foo/bar");
checkFindProject("https://github.com/foo.git", "foo");
checkFindProject("https://github.com/foo/", "foo");
checkFindProject("git+https://github.com/foo", "foo");
checkFindProject("git@github.com/foo", "foo");
checkFindProject("git@github.com:org/internal_repo_name.git", "org/internal_repo_name");
ValidationException e = assertThrows(ValidationException.class, () -> checkFindProject("https://github.com", "foo"));
console.assertThat().onceInLog(MessageType.ERROR, ".*'https://github.com' is not a valid GitHub url.*");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitHubPrOriginTest method testNoCommandLineReference.
@Test
public void testNoCommandLineReference() throws Exception {
ValidationException thrown = assertThrows(ValidationException.class, () -> githubPrOrigin("url = 'https://github.com/google/example'", "required_labels = ['foo: yes', 'bar: yes']").resolve(null));
assertThat(thrown).hasMessageThat().contains("A pull request reference is expected");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitHubPrOriginTest method testGitResolveInvalidReference.
@Test
public void testGitResolveInvalidReference() throws Exception {
ValidationException thrown = assertThrows(ValidationException.class, () -> checkResolve(githubPrOrigin("url = 'https://github.com/google/example'"), "main", 125));
assertThat(thrown).hasMessageThat().contains("'main' is not a valid reference for a GitHub Pull Request");
}
Aggregations