summaryrefslogtreecommitdiff
path: root/tests/unit/test_gitlab_driver.py
diff options
context:
space:
mode:
authorPierre-Louis Bonicoli <pierre-louis.bonicoli@libregerbil.fr>2020-09-15 14:09:17 +0200
committerPierre-Louis Bonicoli <pierre-louis.bonicoli@libregerbil.fr>2020-09-22 11:47:24 +0200
commite8741a7db4a422682f74891af4a001ea92ee6f87 (patch)
tree7475f581dc8becc0aa9c5c91e9a33dd84e97f099 /tests/unit/test_gitlab_driver.py
parentfd519765e6e5119b689e305d6d0748305e2f940e (diff)
downloadzuul-e8741a7db4a422682f74891af4a001ea92ee6f87.tar.gz
gitlab: merge request approval: specify the commit
Avoid approving a merge request which has been updated in the meantime. It can happen when pipeline.dequeue-on-new-patchset is disabled. Change-Id: I6565a1af57b9267022fb3d11002d2d9ffab7a43b
Diffstat (limited to 'tests/unit/test_gitlab_driver.py')
-rw-r--r--tests/unit/test_gitlab_driver.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/unit/test_gitlab_driver.py b/tests/unit/test_gitlab_driver.py
index 11edaf0c4..f1c2eda00 100644
--- a/tests/unit/test_gitlab_driver.py
+++ b/tests/unit/test_gitlab_driver.py
@@ -162,6 +162,27 @@ class TestGitlabDriver(ZuulTestCase):
self.assertEqual('check-approval', zuulvars['pipeline'])
@simple_layout('layouts/basic-gitlab.yaml', driver='gitlab')
+ def test_merge_request_updated_during_build(self):
+
+ A = self.fake_gitlab.openFakeMergeRequest('org/project', 'master', 'A')
+ self.fake_gitlab.emitEvent(A.getMergeRequestOpenedEvent())
+ old = A.sha
+ A.addCommit()
+ new = A.sha
+ self.assertNotEqual(old, new)
+ self.waitUntilSettled()
+
+ self.assertEqual(2, len(self.history))
+ # MR must not be approved: tested commit isn't current commit
+ self.assertFalse(A.approved)
+
+ self.fake_gitlab.emitEvent(A.getMergeRequestUpdatedEvent())
+ self.waitUntilSettled()
+
+ self.assertEqual(4, len(self.history))
+ self.assertTrue(A.approved)
+
+ @simple_layout('layouts/basic-gitlab.yaml', driver='gitlab')
def test_merge_request_labeled(self):
A = self.fake_gitlab.openFakeMergeRequest('org/project', 'master', 'A')