From 1ed1c7f53d829246a85aa65dea2887bfb61be588 Mon Sep 17 00:00:00 2001 From: Tobias Henkel Date: Tue, 25 Feb 2020 17:52:42 +0100 Subject: [PATCH] Test canMerge also with checks api There is no test case for the checks api that validates that canMerge also takes check runs into account if they are required. To test this we can simply add and trigger a gate pipeline after the reporting test case. Change-Id: Icb7e738a5f495e63b70c9a0937087909ff6422e8 --- tests/fixtures/layouts/reporting-github.yaml | 18 ++++++++++++++++++ tests/unit/test_github_driver.py | 9 +++++++++ 2 files changed, 27 insertions(+) diff --git a/tests/fixtures/layouts/reporting-github.yaml b/tests/fixtures/layouts/reporting-github.yaml index 0333d037a9..c35207af12 100644 --- a/tests/fixtures/layouts/reporting-github.yaml +++ b/tests/fixtures/layouts/reporting-github.yaml @@ -97,6 +97,21 @@ github: check: failure +- pipeline: + name: gate + manager: dependent + trigger: + github: + - event: pull_request + action: comment + comment: merge me + success: + github: + status: success + merge: true + failure: + github: {} + - job: name: base parent: null @@ -129,3 +144,6 @@ checks-api-reporting: jobs: - project-test1 + gate: + jobs: + - project-test1 diff --git a/tests/unit/test_github_driver.py b/tests/unit/test_github_driver.py index 6160fa947c..6972136c0b 100644 --- a/tests/unit/test_github_driver.py +++ b/tests/unit/test_github_driver.py @@ -1597,6 +1597,10 @@ class TestGithubAppDriver(ZuulGithubAppTestCase): """Using the checks API only works with app authentication""" project = "org/project3" github = self.fake_github.getGithubClient(None) + repo = github.repo_from_project('org/project3') + repo._set_branch_protection( + 'master', contexts=['tenant-one/checks-api-reporting', + 'tenant-one/gate']) # pipeline reports pull request status both on start and success self.executor_server.hold_jobs_in_build = True @@ -1640,6 +1644,11 @@ class TestGithubAppDriver(ZuulGithubAppTestCase): ) self.assertIsNotNone(check_run["completed_at"]) + # Tell gate to merge to test checks requirements + self.fake_github.emitEvent(A.getCommentAddedEvent('merge me')) + self.waitUntilSettled() + self.assertTrue(A.is_merged) + @simple_layout("layouts/reporting-github.yaml", driver="github") def test_update_non_existing_check_run(self): project = "org/project3"