blob: 1844c3371fa63fdf30689aa0a7185dfae7769e0d [file] [log] [blame]
Jan Hruban3c440b02016-11-11 16:43:31 +01001# 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 Hruban3c440b02016-11-11 16:43:31 +010016from tests.base import ZuulTestCase
17
Jan Hruban3c440b02016-11-11 16:43:31 +010018
19class 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. Blair7c60e442017-06-05 16:37:10 -070031 self.waitUntilSettled()
Jan Hruban3c440b02016-11-11 16:43:31 +010032
33 B = self.fake_github.openFakePullRequest('org/project1', 'master', 'B')
34 self.fake_github.emitEvent(B.getPullRequestOpenedEvent())
Jan Hruban3c440b02016-11-11 16:43:31 +010035 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 Keating28434312017-07-31 11:32:48 -070046
47 # Check on reporting results
48 # github should have a success status (only).
Tobias Henkel3c17d5f2017-08-03 11:46:54 +020049 statuses = self.fake_github.getCommitStatuses(
50 'org/project1', B.head_sha)
Jesse Keating28434312017-07-31 11:32:48 -070051 self.assertEqual(1, len(statuses))
52 self.assertEqual('success', statuses[0]['state'])
53
54 # gerrit should have only reported twice, on start and success
55 self.assertEqual(A.reported, 2)