Skip to content

Commit

Permalink
Add prepare to create PR test with githubAppCheck object
Browse files Browse the repository at this point in the history
  • Loading branch information
hanelliotphan committed Aug 16, 2024
1 parent 1fb97c6 commit ebbb223
Showing 1 changed file with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@
import static org.testng.Assert.assertThrows;

public class PullRequestsTest {
// @Test
// public void testPullRequestsPrepareToCreateSuccessful() throws Exception {
// Map<String, Object> nsMap = ImmutableMap.of(Constants.IMG,
// "image", Constants.TAG,
// "tag", Constants.STORE,
// "store", Constants.SKIP_PR_CREATION,
// false, Constants.CHECK_FOR_RENOVATE, false);
// Namespace ns = new Namespace(nsMap);
// PullRequests pullRequests = new PullRequests();
// GitHubPullRequestSender pullRequestSender = mock(GitHubPullRequestSender.class);
// PagedSearchIterable<GHContent> contentsFoundWithImage = mock(PagedSearchIterable.class);
// GitForkBranch gitForkBranch = mock(GitForkBranch.class);
// DockerfileGitHubUtil dockerfileGitHubUtil = mock(DockerfileGitHubUtil.class);
// RateLimiter rateLimiter = Mockito.spy(new RateLimiter());
// Multimap<String, GitHubContentToProcess> pathToDockerfilesInParentRepo = ArrayListMultimap.create();
// GitHubContentToProcess gitHubContentToProcess = mock(GitHubContentToProcess.class);
// pathToDockerfilesInParentRepo.put("repo1", gitHubContentToProcess);
// pathToDockerfilesInParentRepo.put("repo2", gitHubContentToProcess);
// when(pullRequestSender.forkRepositoriesFoundAndGetPathToDockerfiles(contentsFoundWithImage, gitForkBranch)).thenReturn(pathToDockerfilesInParentRepo);
//
//
// pullRequests.prepareToCreate(ns, pullRequestSender, contentsFoundWithImage,
// gitForkBranch, dockerfileGitHubUtil, rateLimiter);
//
// verify(dockerfileGitHubUtil, times(2)).changeDockerfiles(eq(ns),
// eq(pathToDockerfilesInParentRepo),
// eq(gitHubContentToProcess), anyList(), eq(gitForkBranch),
// eq(rateLimiter));
// }
@Test
public void testPullRequestsPrepareToCreateSuccessful() throws Exception {
Map<String, Object> nsMap = ImmutableMap.of(Constants.IMG,
"image", Constants.TAG,
"tag", Constants.STORE,
"store", Constants.SKIP_PR_CREATION,
false, Constants.CHECK_FOR_RENOVATE, false);
Namespace ns = new Namespace(nsMap);
PullRequests pullRequests = new PullRequests();
GitHubPullRequestSender pullRequestSender = mock(GitHubPullRequestSender.class);
PagedSearchIterable<GHContent> contentsFoundWithImage = mock(PagedSearchIterable.class);
GitForkBranch gitForkBranch = mock(GitForkBranch.class);
DockerfileGitHubUtil dockerfileGitHubUtil = mock(DockerfileGitHubUtil.class);
GithubAppCheck githubAppCheck = mock(GithubAppCheck.class);
RateLimiter rateLimiter = Mockito.spy(new RateLimiter());
Multimap<String, GitHubContentToProcess> pathToDockerfilesInParentRepo = ArrayListMultimap.create();
GitHubContentToProcess gitHubContentToProcess = mock(GitHubContentToProcess.class);
pathToDockerfilesInParentRepo.put("repo1", gitHubContentToProcess);
pathToDockerfilesInParentRepo.put("repo2", gitHubContentToProcess);
when(pullRequestSender.forkRepositoriesFoundAndGetPathToDockerfiles(contentsFoundWithImage, gitForkBranch)).thenReturn(pathToDockerfilesInParentRepo);

pullRequests.prepareToCreate(ns, pullRequestSender, contentsFoundWithImage,
gitForkBranch, dockerfileGitHubUtil, rateLimiter);

verify(dockerfileGitHubUtil, times(2)).changeDockerfiles(eq(ns),
eq(pathToDockerfilesInParentRepo),
eq(gitHubContentToProcess), anyList(), eq(gitForkBranch),
eq(rateLimiter));
}

// @Test(expectedExceptions = IOException.class)
// public void testPullRequestsPrepareThrowsException() throws Exception {
Expand Down

0 comments on commit ebbb223

Please sign in to comment.