use of com.google.copybara.exception.EmptyChangeException in project copybara by google.
the class GitHubPrOriginTest method gitResolveRequiredStatusContextNamesFail.
@Test
public void gitResolveRequiredStatusContextNamesFail() throws Exception {
MockPullRequest.create(gitUtil).setState("open").setPrNumber(125).addLabels("bar: yes").addCommitStatus("foo/one", "success").addCommitStatus("foo/two", "failure").mock();
EmptyChangeException thrown = assertThrows(EmptyChangeException.class, () -> checkResolve(githubPrOrigin("url = 'https://github.com/google/example'", "required_status_context_names = ['foo/one', 'foo/two']"), sha, 125));
assertThat(thrown).hasMessageThat().contains("Cannot migrate http://github.com/google/example/pull/125 because the following ci" + " labels have not been passed: [foo/two]");
}
use of com.google.copybara.exception.EmptyChangeException in project copybara by google.
the class GitHubPrOriginTest method gitResolveRequiredCheckRunsNotFoundOpenPR.
@Test
public void gitResolveRequiredCheckRunsNotFoundOpenPR() throws Exception {
MockPullRequest.create(gitUtil).setState("closed").setPrNumber(125).addLabels("bar: yes").mock();
EmptyChangeException thrown = assertThrows(EmptyChangeException.class, () -> checkResolve(githubPrOrigin("url = 'https://github.com/google/example'", "required_check_runs = ['foo/one', 'foo/two']"), sha, 125));
assertThat(thrown).hasMessageThat().contains("Could not find a pr with OPEN state and head being equal to sha " + sha);
}
use of com.google.copybara.exception.EmptyChangeException in project copybara by google.
the class GitHubPrOriginTest method testGitResolveRequiredLabelsNotFound.
@Test
public void testGitResolveRequiredLabelsNotFound() throws Exception {
MockPullRequest.create(gitUtil).setState("open").setPrNumber(125).addLabels("bar: yes").mock();
EmptyChangeException thrown = assertThrows(EmptyChangeException.class, () -> checkResolve(githubPrOrigin("url = 'https://github.com/google/example'", "required_labels = ['foo: yes', 'bar: yes']"), "125", 125));
assertThat(thrown).hasMessageThat().contains("Cannot migrate http://github.com/google/example/pull/125 because it is missing the" + " following labels: [foo: yes]");
}
use of com.google.copybara.exception.EmptyChangeException in project copybara by google.
the class GitHubPrOriginTest method testAlreadyClosed_only_open.
@Test
public void testAlreadyClosed_only_open() throws Exception {
MockPullRequest.create(gitUtil).setState("closed").setPrNumber(125).addLabels("foo: yes").mock();
EmptyChangeException thrown = assertThrows(EmptyChangeException.class, () -> checkResolve(githubPrOrigin("url = 'https://github.com/google/example', state = 'OPEN'"), "125", 125));
assertThat(thrown).hasMessageThat().contains("Pull Request 125 is closed");
}
use of com.google.copybara.exception.EmptyChangeException in project copybara by google.
the class GitHubPrOriginTest method testReviewApprovers.
@Test
public void testReviewApprovers() throws Exception {
GitRevision noReviews = checkReviewApprovers();
assertThat(noReviews.associatedLabels()).doesNotContainKey(GitHubPrOrigin.GITHUB_PR_REVIEWER_APPROVER);
assertThat(noReviews.associatedLabels()).doesNotContainKey(GitHubPrOrigin.GITHUB_PR_REVIEWER_OTHER);
GitRevision any = checkReviewApprovers("review_state = 'ANY'");
assertThat(any.associatedLabels().get(GitHubPrOrigin.GITHUB_PR_REVIEWER_APPROVER)).containsExactly("APPROVED_MEMBER", "COMMENTED_OWNER", "APPROVED_COLLABORATOR");
assertThat(any.associatedLabels().get(GitHubPrOrigin.GITHUB_PR_REVIEWER_OTHER)).containsExactly("COMMENTED_OTHER");
EmptyChangeException e = assertThrows(EmptyChangeException.class, () -> checkReviewApprovers("review_state = 'HEAD_COMMIT_APPROVED'", "review_approvers = [\"MEMBER\", \"OWNER\"]"));
assertThat(e).hasMessageThat().contains("missing the required approvals");
assertThat(e).hasMessageThat().contains("MEMBER");
assertThat(e).hasMessageThat().contains("OWNER");
assertThat(e).hasMessageThat().contains("User APPROVED_COLLABORATOR - Association: COLLABORATOR");
assertThat(e).hasMessageThat().contains("User COMMENTED_OTHER - Association: NONE");
GitRevision hasReviewers = checkReviewApprovers("review_state = 'ANY_COMMIT_APPROVED'", "review_approvers = [\"MEMBER\", \"OWNER\"]");
assertThat(hasReviewers.associatedLabels().get(GitHubPrOrigin.GITHUB_PR_REVIEWER_APPROVER)).containsExactly("APPROVED_MEMBER", "COMMENTED_OWNER");
assertThat(hasReviewers.associatedLabels().get(GitHubPrOrigin.GITHUB_PR_REVIEWER_OTHER)).containsExactly("COMMENTED_OTHER", "APPROVED_COLLABORATOR");
GitRevision anyCommitApproved = checkReviewApprovers("review_state = 'HAS_REVIEWERS'", "review_approvers = [\"OWNER\"]");
assertThat(anyCommitApproved.associatedLabels().get(GitHubPrOrigin.GITHUB_PR_REVIEWER_APPROVER)).containsExactly("COMMENTED_OWNER");
assertThat(anyCommitApproved.associatedLabels().get(GitHubPrOrigin.GITHUB_PR_REVIEWER_OTHER)).containsExactly("APPROVED_MEMBER", "COMMENTED_OTHER", "APPROVED_COLLABORATOR");
}
Aggregations