Skip to content

Commit dc41d7b

Browse files
committed
Add tests for the allowPlainMerge setting
1 parent 3bf844b commit dc41d7b

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

tests/Spec.hs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6562,3 +6562,70 @@ main = hspec $ do
65626562
}
65636563
, ALeaveComment (PullRequestId 1) "<!-- Hoff: ignore -->\nRebased as 1b3, waiting for CI …"
65646564
]
6565+
6566+
it "disallows plain merge on a repo configured with ProjectConfiguration.allowPlainMerge=False" $ do
6567+
let
6568+
prId = PullRequestId 1
6569+
state = singlePullRequestState prId (Branch "p") masterBranch (Sha "abc1234") "tyrell"
6570+
6571+
event = CommentAdded prId "deckard" Nothing "@bot merge"
6572+
6573+
results = defaultResults{resultIntegrate = [Right (Sha "def2345")]}
6574+
(_, actions) = runActionCustom' results (testProjectConfig{Config.allowPlainMerge = Just False}) $ handleEventTest event state
6575+
6576+
actions
6577+
`shouldBe` [ AIsReviewer "deckard"
6578+
, ALeaveComment prId "Your merge request has been denied because this project can be automatically deployed. Use 'merge without deploying' if you really don't want to deploy after merging."
6579+
]
6580+
6581+
it "allows merge without deploying on a repo configured with ProjectConfiguration.allowPlainMerge=False" $ do
6582+
let
6583+
prId = PullRequestId 1
6584+
state = singlePullRequestState prId (Branch "p") masterBranch (Sha "abc1234") "tyrell"
6585+
6586+
event = CommentAdded prId "deckard" Nothing "@bot merge without deploying"
6587+
6588+
results = defaultResults{resultIntegrate = [Right (Sha "def2345")]}
6589+
(_, actions) = runActionCustom' results (testProjectConfig{Config.allowPlainMerge = Just False}) $ handleEventTest event state
6590+
6591+
actions
6592+
`shouldBe` [ AIsReviewer "deckard"
6593+
, ALeaveComment
6594+
prId
6595+
"<!-- Hoff: ignore -->\nPull request approved for merge without deploying by @deckard, rebasing now."
6596+
, ATryIntegrate
6597+
"Merge #1: Untitled\n\n\
6598+
\Approved-by: deckard\n\
6599+
\Priority: Normal\n\
6600+
\Auto-deploy: false\n"
6601+
(prId, Branch "refs/pull/1/head", Sha "abc1234")
6602+
[]
6603+
False
6604+
, ALeaveComment prId "<!-- Hoff: ignore -->\nRebased as def2345, waiting for CI …"
6605+
]
6606+
6607+
it "allows merge without deploying on a repo configured with ProjectConfiguration.allowPlainMerge=True" $ do
6608+
let
6609+
prId = PullRequestId 1
6610+
state = singlePullRequestState prId (Branch "p") masterBranch (Sha "abc1234") "tyrell"
6611+
6612+
event = CommentAdded prId "deckard" Nothing "@bot merge without deploying"
6613+
6614+
results = defaultResults{resultIntegrate = [Right (Sha "def2345")]}
6615+
(_, actions) = runActionCustom results $ handleEventTest event state
6616+
6617+
actions
6618+
`shouldBe` [ AIsReviewer "deckard"
6619+
, ALeaveComment
6620+
prId
6621+
"<!-- Hoff: ignore -->\nPull request approved for merge without deploying by @deckard, rebasing now."
6622+
, ATryIntegrate
6623+
"Merge #1: Untitled\n\n\
6624+
\Approved-by: deckard\n\
6625+
\Priority: Normal\n\
6626+
\Auto-deploy: false\n"
6627+
(prId, Branch "refs/pull/1/head", Sha "abc1234")
6628+
[]
6629+
False
6630+
, ALeaveComment prId "<!-- Hoff: ignore -->\nRebased as def2345, waiting for CI …"
6631+
]

0 commit comments

Comments
 (0)