Commit ff3e9fda authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Git: test for manual merge detection

It's still far from being comprehensive, but it did catch
something to be fixed.
parent fad9501f6d87
Pipeline #12769 passed with stage
in 24 minutes and 32 seconds
......@@ -3,6 +3,28 @@ from .utils.git import LocalRepo as GitRepo
from .utils.runner import Runner
from .test_merge_requests import api_accept_merge_request
def assert_merge_detected(project, mr_id, target_branch=None, timeout=10):
"""Checks that merge has been detected in given MR and a bit more
:param named_branch: if not passed, the source GitLab branch is assumed to
be a topic.
mr_id = str(mr_id)
# Detection assessment.
# Since detection is asynchronous, it can be delayed,
# especially if under stress (concurrent and load tests)
mr_id, lambda mr: mr.get('state') == 'merged',
msg="Merge not detected")
# Web UI for the merge request is not broken
webdriver = project.owner_webdriver
webdriver.get(project.url + '/merge_requests/' + mr_id)
assert '(500)' not in webdriver.title
def test_basic(git_project, tmpdir):
proj = git_project
repo_path = tmpdir.join('repo')
......@@ -163,3 +185,36 @@ def test_mergerequest_api_explicit_merge_message(git_project, tmpdir):
assert vcs_info['repo_type'] == 'git'
assert vcs_info['sha'] == repo.sha('origin/master')
assert vcs_info.get('hgsha') is None
def test_mergerequest_cli(git_project, tmpdir):
"""Accepting the MR via a manual push, with an explicit merge changeset.
proj = git_project
runner = Runner.api_register(git_project, 'explicit')
default_url = proj.owner_basic_auth_url
repo = GitRepo.init(tmpdir.join('repo'),
src_branch = prepare_mr_source_branch(repo, with_ci=True)
jobs = runner.wait_assert_jobs(2)
assert set(job['git_info']['ref']
for job in jobs) == {'master', 'antelope'}
mr_id = proj.api_create_merge_request(source=src_branch, target='master')
repo.git('checkout', 'master')
repo.git('merge', '-m', "merged 'antelope manually", 'antelope')
print("Graph after CLI merge:")
repo.git('push', 'origin', 'master')
assert_merge_detected(proj, mr_id)
# there's a CI job for the target
job = runner.wait_assert_one_job()
vcs_info = job['git_info']
assert vcs_info['ref'] == 'master'
assert vcs_info['repo_type'] == 'git'
assert vcs_info['sha'] == repo.sha('origin/master')
assert vcs_info.get('hgsha') is None
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