private async Task OpenBlackListPullRequest(string owner, string repo, int prId, string sha) { var payloadString = await File.ReadAllTextAsync("../../../DummyEvents/PullRequest.json"); var payload = JsonConvert.DeserializeObject <dynamic>(payloadString); await MockCommentGithubCallHelper.MockCommentGithubCallBlackListPrOpened(owner, repo, prId); payload["repository"]["name"] = repo; payload["repository"]["owner"]["login"] = owner; payload["pull_request"]["head"]["sha"] = sha; payload["pull_request"]["number"] = prId; payload["number"] = prId; // ACTION await SendWebhookRequest("pull_request", JsonConvert.SerializeObject(payload)); }
public async Task ReceivePullRequestEvent_ActionIsOpened_BlacklistMergePolicyAndWipInTitle_CommentToUser() { var payloadString = await File.ReadAllTextAsync("../../../DummyEvents/PullRequest.json"); var payload = JsonConvert.DeserializeObject <dynamic>(payloadString); var owner = Guid.NewGuid().ToString(); var repo = Guid.NewGuid().ToString(); var sha = Guid.NewGuid().ToString(); var title = "[WIP] title of PR"; await checkListsCollection.InsertWithDefaultChecks(owner, repo); await repoConfigurationCollection.Insert(owner, repo, "oldest", "blacklist"); // Mock Github call to add miro merge status check var miroMergeCheckCallId = await MockGithubCall("post", StatusCheckUrlFor(owner, repo, sha), "pending", "{}", false); var blackListCommentCallId = await MockCommentGithubCallHelper.MockCommentGithubCallBlackListPrOpened(owner, repo, PR_ID); payload["repository"]["name"] = repo; payload["repository"]["owner"]["login"] = owner; payload["pull_request"]["head"]["sha"] = sha; payload["pull_request"]["title"] = title; // ACTION await SendWebhookRequest("pull_request", JsonConvert.SerializeObject(payload)); // ASSERT var miroMergeCheckCall = await GetCall(miroMergeCheckCallId); var blackListCommentCall = await GetCall(blackListCommentCallId); var mergeRequest = await mergeRequestsCollection.Collection.Find(d => d["Owner"] == owner && d["Repo"] == repo && d["PrId"] == PR_ID).FirstAsync(); Assert.False((bool)mergeRequest["ReceivedMergeCommand"]); Assert.True(blackListCommentCall.HasBeenMade, "should have gotten a comment about blacklist Pullrequest"); Assert.False(miroMergeCheckCall.HasBeenMade, "should not have gotten a call to add the miro check"); }