Jan Hruban | 3c440b0 | 2016-11-11 16:43:31 +0100 | [diff] [blame] | 1 | # Copyright 2015 GoodData |
| 2 | # Copyright (c) 2017 IBM Corp. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
Jan Hruban | 3c440b0 | 2016-11-11 16:43:31 +0100 | [diff] [blame] | 16 | from tests.base import ZuulTestCase |
| 17 | |
Jan Hruban | 3c440b0 | 2016-11-11 16:43:31 +0100 | [diff] [blame] | 18 | |
| 19 | class TestGerritAndGithub(ZuulTestCase): |
| 20 | config_file = 'zuul-connections-gerrit-and-github.conf' |
| 21 | tenant_config_file = 'config/multi-driver/main.yaml' |
| 22 | |
| 23 | def setup_config(self): |
| 24 | super(TestGerritAndGithub, self).setup_config() |
| 25 | |
| 26 | def test_multiple_project_gerrit_and_github(self): |
| 27 | self.executor_server.hold_jobs_in_build = True |
| 28 | |
| 29 | A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A') |
| 30 | self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1)) |
James E. Blair | 7c60e44 | 2017-06-05 16:37:10 -0700 | [diff] [blame] | 31 | self.waitUntilSettled() |
Jan Hruban | 3c440b0 | 2016-11-11 16:43:31 +0100 | [diff] [blame] | 32 | |
| 33 | B = self.fake_github.openFakePullRequest('org/project1', 'master', 'B') |
| 34 | self.fake_github.emitEvent(B.getPullRequestOpenedEvent()) |
Jan Hruban | 3c440b0 | 2016-11-11 16:43:31 +0100 | [diff] [blame] | 35 | self.waitUntilSettled() |
| 36 | |
| 37 | self.assertEqual(2, len(self.builds)) |
| 38 | self.assertEqual('project-gerrit', self.builds[0].name) |
| 39 | self.assertEqual('project1-github', self.builds[1].name) |
| 40 | self.assertTrue(self.builds[0].hasChanges(A)) |
| 41 | self.assertTrue(self.builds[1].hasChanges(B)) |
| 42 | |
| 43 | self.executor_server.hold_jobs_in_build = False |
| 44 | self.executor_server.release() |
| 45 | self.waitUntilSettled() |
Jesse Keating | 2843431 | 2017-07-31 11:32:48 -0700 | [diff] [blame] | 46 | |
| 47 | # Check on reporting results |
| 48 | # github should have a success status (only). |
| 49 | statuses = self.fake_github.statuses['org/project1'][B.head_sha] |
| 50 | self.assertEqual(1, len(statuses)) |
| 51 | self.assertEqual('success', statuses[0]['state']) |
| 52 | |
| 53 | # gerrit should have only reported twice, on start and success |
| 54 | self.assertEqual(A.reported, 2) |