summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2021-05-23 14:39:55 -0700
committerJohn L. Villalovos <john@sodarock.com>2021-05-25 14:54:13 -0700
commitcd5993c9d638c2a10879d7e3ac36db06df867e54 (patch)
treedfda9c50f0619191c282f95a8790655d200a4385
parent7d66115573c6c029ce6aa00e244f8bdfbb907e33 (diff)
downloadgitlab-cd5993c9d638c2a10879d7e3ac36db06df867e54.tar.gz
chore: add functional test mr.merge() with long commit message
Functional test to show that https://github.com/python-gitlab/python-gitlab/issues/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
-rw-r--r--tools/functional/api/test_merge_requests.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/tools/functional/api/test_merge_requests.py b/tools/functional/api/test_merge_requests.py
index 80a650c..abb1668 100644
--- a/tools/functional/api/test_merge_requests.py
+++ b/tools/functional/api/test_merge_requests.py
@@ -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