summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2021-05-23 10:44:27 -0700
committerJohn L. Villalovos <john@sodarock.com>2021-05-25 14:54:13 -0700
commit7d66115573c6c029ce6aa00e244f8bdfbb907e33 (patch)
tree992d0f9c48d2f0c5f93c742a585f74b8194c694f
parent184b94bbe8da5595b06d187e30041e3331b6db8b (diff)
downloadgitlab-7d66115573c6c029ce6aa00e244f8bdfbb907e33.tar.gz
chore: add a functional test for issue #1120
Going to switch to putting parameters from in the query string to having them in the 'data' body section. Add a functional test to make sure that we don't break anything. https://github.com/python-gitlab/python-gitlab/issues/1120
-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 c5de5eb..80a650c 100644
--- a/tools/functional/api/test_merge_requests.py
+++ b/tools/functional/api/test_merge_requests.py
@@ -1,6 +1,9 @@
+import time
+
import pytest
import gitlab
+import gitlab.v4.objects
def test_merge_requests(project):
@@ -95,3 +98,59 @@ def test_merge_request_merge(project):
with pytest.raises(gitlab.GitlabMRClosedError):
# Two merge attempts should raise GitlabMRClosedError
mr.merge()
+
+
+def test_merge_request_should_remove_source_branch(
+ project: gitlab.v4.objects.Project, wait_for_sidekiq
+):
+ """Test to ensure https://github.com/python-gitlab/python-gitlab/issues/1120
+ is fixed"""
+
+ source_branch = "remove_source_branch"
+ 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": "Should remove source branch",
+ "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)
+
+ mr.merge(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