Add a test which exercises a speculative role checkout
We didn't have coverage for the code which identifies that a role
needed for a job is one that is already checked out because there
is a proposed change for that role being tested. This adds a test
for that sitution.
Change-Id: If5c5ee8cd103b9e90a65a120fd6082656846c597
diff --git a/tests/unit/test_v3.py b/tests/unit/test_v3.py
index 3919418..4006406 100644
--- a/tests/unit/test_v3.py
+++ b/tests/unit/test_v3.py
@@ -339,3 +339,21 @@
# Make sure it's the right length
self.assertEqual(4096, private_key.key_size)
+
+
+class TestRoles(ZuulTestCase):
+ tenant_config_file = 'config/roles/main.yaml'
+
+ def test_role(self):
+ # This exercises a proposed change to a role being checked out
+ # and used.
+ A = self.fake_gerrit.addFakeChange('bare-role', 'master', 'A')
+ B = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
+ B.data['commitMessage'] = '%s\n\nDepends-On: %s\n' % (
+ B.subject, A.data['id'])
+ self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
+ self.fake_gerrit.addEvent(B.getPatchsetCreatedEvent(1))
+ self.waitUntilSettled()
+ self.assertHistory([
+ dict(name='project-test', result='SUCCESS', changes='1,1 2,1'),
+ ])