diff --git a/tests/Spec.hs b/tests/Spec.hs index 17b9541a..404516d5 100644 --- a/tests/Spec.hs +++ b/tests/Spec.hs @@ -2103,6 +2103,78 @@ main = hspec $ do \ do not belong to any other commits." ] + it "new commits on conflicted PRs should not reset other PRs in the train\ + \(success, wrongfixups (success), success)" $ do + let + state + = Project.insertPullRequest (PullRequestId 1) (Branch "fst") masterBranch (Sha "ab1") "First PR" (Username "tyrell") + $ Project.insertPullRequest (PullRequestId 2) (Branch "snd") masterBranch (Sha "cd2") "Second PR" (Username "rachael") + $ Project.insertPullRequest (PullRequestId 3) (Branch "trd") masterBranch (Sha "ef3") "Third PR" (Username "tyrell") + $ Project.emptyProjectState + events = + [ CommentAdded (PullRequestId 1) "deckard" "@bot merge" + , CommentAdded (PullRequestId 2) "deckard" "@bot merge" + , CommentAdded (PullRequestId 3) "deckard" "@bot merge" + , PullRequestCommitChanged (PullRequestId 2) (Sha "c2d") + , CommentAdded (PullRequestId 2) "deckard" "@bot merge" + ] + results = defaultResults { resultIntegrate = [ Right (Sha "1ab") + , Left (IntegrationFailure (BaseBranch "testing/1") WrongFixups) + , Right (Sha "3cd") + , Right (Sha "2bc") ] } + run = runActionCustom results + actions = snd $ run $ handleEventsTest events state + actions `shouldBe` + [ AIsReviewer "deckard" + , ALeaveComment (PullRequestId 1) + "Pull request approved for merge by @deckard, rebasing now." + , ATryIntegrate "Merge #1: First PR\n\n\ + \Approved-by: deckard\n\ + \Auto-deploy: false\n" + (PullRequestId 1, Branch "refs/pull/1/head", Sha "ab1") + [] + False + , ALeaveComment (PullRequestId 1) "Rebased as 1ab, waiting for CI …" + , AIsReviewer "deckard" + , ALeaveComment (PullRequestId 2) + "Pull request approved for merge by @deckard, \ + \waiting for rebase behind one pull request." + , ATryIntegrate "Merge #2: Second PR\n\n\ + \Approved-by: deckard\n\ + \Auto-deploy: false\n" + (PullRequestId 2, Branch "refs/pull/2/head", Sha "cd2") + [PullRequestId 1] + False + , ALeaveComment (PullRequestId 2) + "Pull request cannot be integrated\ + \ as it contains fixup commits that\ + \ do not belong to any other commits." + , AIsReviewer "deckard" + , ALeaveComment (PullRequestId 3) + "Pull request approved for merge by @deckard, \ + \waiting for rebase behind one pull request." + , ATryIntegrate "Merge #3: Third PR\n\n\ + \Approved-by: deckard\n\ + \Auto-deploy: false\n" + (PullRequestId 3, Branch "refs/pull/3/head", Sha "ef3") + [PullRequestId 1] + False + , ALeaveComment (PullRequestId 3) "Speculatively rebased as 3cd behind #1, waiting for CI …" + -- upon commit changed on PR#2, there is no reason to reintegrate PR#3 + -- PR#2 is moved to the end of the train after a new merge command + , AIsReviewer "deckard" + , ALeaveComment (PullRequestId 2) + "Pull request approved for merge by @deckard, \ + \waiting for rebase behind 2 pull requests." + , ATryIntegrate "Merge #2: Second PR\n\n\ + \Approved-by: deckard\n\ + \Auto-deploy: false\n" + (PullRequestId 2, Branch "refs/pull/2/head", Sha "c2d") + [PullRequestId 1, PullRequestId 3] + False + , ALeaveComment (PullRequestId 2) "Speculatively rebased as 2bc behind #1 and #3, waiting for CI …" + ] + it "handles a 2-wagon merge train with build successes coming in the right order: success (1), success (2)" $ do let state