blob: 1cfadf4703dea951c8c7f894eaa3444fb48b2d3a [file] [log] [blame]
James E. Blair45de61c2017-02-14 13:23:14 -08001# Copyright 2016 Red Hat, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from tests.base import ZuulTestCase
16
17
18class TestGitDriver(ZuulTestCase):
19 config_file = 'zuul-git-driver.conf'
20 tenant_config_file = 'config/git-driver/main.yaml'
21
22 def setup_config(self):
23 super(TestGitDriver, self).setup_config()
24 self.config.set('connection git', 'baseurl', self.upstream_root)
25
26 def test_git_driver(self):
27 tenant = self.sched.abide.tenants.get('tenant-one')
28 # Check that we have the git source for common-config and the
29 # gerrit source for the project.
James E. Blair109da3f2017-04-04 14:39:43 -070030 self.assertEqual('git', tenant.config_projects[0].source.name)
31 self.assertEqual('common-config', tenant.config_projects[0].name)
32 self.assertEqual('gerrit', tenant.untrusted_projects[0].source.name)
33 self.assertEqual('org/project', tenant.untrusted_projects[0].name)
James E. Blair45de61c2017-02-14 13:23:14 -080034
35 # The configuration for this test is accessed via the git
36 # driver (in common-config), rather than the gerrit driver, so
37 # if the job runs, it worked.
38 A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
39 self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
40 self.waitUntilSettled()
41 self.assertEqual(len(self.history), 1)
42 self.assertEqual(A.reported, 1)