use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitMirrorTest method testDefaultMirrorInStarlark_invalid_destination.
@Test
public void testDefaultMirrorInStarlark_invalid_destination() throws Exception {
String cfg = "" + NATIVE_MIRROR_IN_STARLARK_FUNC + "git.mirror(" + " name = 'default'," + " origin = 'file://" + originRepo.getGitDir().toAbsolutePath() + "'," + " destination = 'file://" + destRepo.getGitDir().toAbsolutePath() + "'," + " refspecs = [" + String.format(" 'refs/heads/%s:refs/heads/origin_primary'", primaryBranch) + " ]," + " actions = [native_mirror(refspec = {" + String.format(" 'refs/heads/%s':'refs/heads/INVALID'", primaryBranch) + "})]," + ")";
Migration mirror = loadMigration(cfg, "default");
ValidationException ve = assertThrows(ValidationException.class, () -> mirror.run(workdir, ImmutableList.of()));
assertThat(ve).hasMessageThat().contains("Action tried to push to destination one or more refspec not covered by git.mirror");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitMirrorTest method testActionFailure.
@Test
public void testActionFailure() throws Exception {
ValidationException ve = checkActionFailure();
assertThat(ve).hasMessageThat().contains("Something bad happened");
assertThat(ve).hasMessageThat().doesNotContain("Another thing bad happened");
console.assertThat().onceInLog(MessageType.INFO, "Hello, this is action1");
console.assertThat().timesInLog(0, MessageType.INFO, "Hello, this is action2");
console.assertThat().timesInLog(0, MessageType.INFO, "Hello, this is action3");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitHubEndpointTest method testGetPullRequestComment_invalidId.
@Test
public void testGetPullRequestComment_invalidId() {
ValidationException expected = assertThrows(ValidationException.class, () -> runFeedback(ImmutableList.of("ctx.destination.get_pull_request_comment(comment_id = 'foo')")));
assertThat(expected).hasMessageThat().contains("Invalid comment id foo");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitHubEndpointTest method testGetPullRequestComments_notFound.
@Test
public void testGetPullRequestComments_notFound() {
gitUtil.mockApi(eq("GET"), eq("https://api.github.com/repos/google/example/pulls/12345/comments?per_page=100"), mockGitHubNotFound());
ValidationException expected = assertThrows(ValidationException.class, () -> runFeedback(ImmutableList.of("ctx.destination.get_pull_request_comments(number = 12345)")));
assertThat(expected).hasMessageThat().contains("Pull Request Comments not found");
}
use of com.google.copybara.exception.ValidationException in project copybara by google.
the class GitHubEndpointTest method testCreateStatusLimitReached.
@Test
public void testCreateStatusLimitReached() throws Exception {
gitUtil.mockApi(eq("POST"), contains("/statuses/c59774"), mockResponseWithStatus("{\n" + "\"message\" : \"This SHA and context has reached the maximum number of statuses\",\n" + "\"documentation_url\" : \"https://developer.github.com/v3\"\n" + "}", 422, ALWAYS_TRUE));
ValidationException expected = assertThrows(ValidationException.class, () -> runFeedback(ImmutableList.<String>builder().add("ctx.destination.create_status(" + "sha = 'c597746de9c1704e648ddc3ffa0d2096b146d600'," + " state = 'success', context = 'test', description = 'Observed foo')").build()));
assertThat(expected).hasMessageThat().contains("This SHA and context has reached the maximum number of statuses");
}
Aggregations