Skip to content

Commit

Permalink
chore: add functional test mr.merge() with long commit message
Browse files Browse the repository at this point in the history
Functional test to show that
#1452 is fixed.

Added a functional test to ensure that we can use large commit message
(10_000+ bytes) in mr.merge()

Related to: #1452
  • Loading branch information
JohnVillalovos committed May 25, 2021
1 parent 7d66115 commit cd5993c
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tools/functional/api/test_merge_requests.py
Expand Up @@ -154,3 +154,62 @@ def test_merge_request_should_remove_source_branch(

mr = project.mergerequests.get(mr.iid)
assert mr.merged_at is not None # Now is merged


def test_merge_request_large_commit_message(
project: gitlab.v4.objects.Project, wait_for_sidekiq
):
"""Test to ensure https://github.com/python-gitlab/python-gitlab/issues/1452
is fixed"""
source_branch = "large_commit_message"
project.branches.create({"branch": source_branch, "ref": "master"})

# NOTE(jlvillal): Must create a commit in the new branch before we can
# create an MR that will work.
project.files.create(
{
"file_path": f"README.{source_branch}",
"branch": source_branch,
"content": "Initial content",
"commit_message": "New commit in new branch",
}
)

mr = project.mergerequests.create(
{
"source_branch": source_branch,
"target_branch": "master",
"title": "Large Commit Message",
"remove_source_branch": True,
}
)

result = wait_for_sidekiq(timeout=60)
assert result is True, "sidekiq process should have terminated but did not"

mr_iid = mr.iid
for _ in range(60):
mr = project.mergerequests.get(mr_iid)
if mr.merge_status != "checking":
break
time.sleep(0.5)
assert mr.merge_status != "checking"

# Ensure we can get the MR branch
project.branches.get(source_branch)

commit_message = "large_message\r\n" * 1_000
assert len(commit_message) > 10_000
assert mr.merged_at is None # Not yet merged

mr.merge(merge_commit_message=commit_message, should_remove_source_branch=True)

result = wait_for_sidekiq(timeout=60)
assert result is True, "sidekiq process should have terminated but did not"

# Ensure we can NOT get the MR branch
with pytest.raises(gitlab.exceptions.GitlabGetError):
project.branches.get(source_branch)

mr = project.mergerequests.get(mr.iid)
assert mr.merged_at is not None # Now is merged

0 comments on commit cd5993c

Please sign in to comment.