use of com.google.copybara.git.github.api.GitHubApiException in project copybara by google.
the class GitHubDestinationTest method testWithGitHubApiError.
@Test
public void testWithGitHubApiError() throws Exception {
gitUtil.mockApi("GET", "https://api.github.com/repos/foo/git/refs/heads/other_12345", mockResponseWithStatus("", 403));
gitUtil.mockApi("GET", "https://api.github.com/repos/foo/git/refs/other_6789", mockResponseWithStatus("", 403));
addFiles(remote, primaryBranch, "first change", ImmutableMap.<String, String>builder().put("foo.txt", "foo").buildOrThrow());
WriterContext writerContext = new WriterContext("piper_to_github", "test", false, new DummyRevision("origin_ref1"), Glob.ALL_FILES.roots());
Writer<GitRevision> writer = destinationWithExistingPrBranch("other_${my_label}", /*deletePrBranch=*/
"None").newWriter(writerContext);
GitHubApiException e = assertThrows(GitHubApiException.class, () -> process(writer, new DummyRevision("origin_ref1")));
Assert.assertSame(e.getResponseCode(), FORBIDDEN);
}
Aggregations