Commit d2f034621e6 by Georges Racinet

Test detection of conflicting merge request

This works right away, has been written while investigating
heptapod#131 and heptapod#99
parent 219e401d2a0
Pipeline #1443 passed with stage
in 13 seconds
......@@ -117,7 +117,7 @@ def assert_merge_detected(project, mr_id, named_branch=None):
assert source_branch in project.api_branches()
def api_accept_merge_request(proj, mr_id):
def api_accept_merge_request(proj, mr_id, check_merged=True):
# we need the id of the project
# (TODO) make a cached property for this
resp = proj.owner_api_get()
......@@ -127,6 +127,9 @@ def api_accept_merge_request(proj, mr_id):
resp = proj.owner_api_put(subpath='merge_requests/%s/merge' % mr_id,
if not check_merged:
return resp
assert resp.status_code == 200
mr = resp.json()
assert mr['state'] == 'merged'
......@@ -275,6 +278,27 @@ def test_mergerequest_api_explicit_merge_message(test_project, tmpdir):
def test_mergerequest_api_conflict(test_project, tmpdir):
repo = hg.LocalRepo.init(tmpdir.join('repo'),
repo.path.join('horse').write("A lion is stronger than a donkey\n")
repo.hg('commit', '-Am', "Même un âne",
'--user', 'Raphaël <raphael@heptapod.test>')
mr_id = test_project.create_merge_request()
resp = test_project.owner_api_get(subpath='merge_requests/%s' % mr_id)
assert resp.status_code == 200
assert resp.json()['merge_status'] == 'cannot_be_merged'
resp = api_accept_merge_request(test_project, mr_id, check_merged=False)
# on current GitLab 10.3, that's 405, but doc of 12.3 says it will
# become a 406 at some point
assert resp.status_code in (405, 406)
def test_mergerequest_api_explicit_merge_user(public_project, tmpdir):
"""Accepting the MR via API with rebase scenario.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment