James E. Blair | 45de61c | 2017-02-14 13:23:14 -0800 | [diff] [blame] | 1 | # 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 | |
| 15 | from tests.base import ZuulTestCase |
| 16 | |
| 17 | |
| 18 | class 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. |
| 30 | self.assertEqual('git', tenant.config_repos[0][0].name) |
| 31 | self.assertEqual('common-config', tenant.config_repos[0][1].name) |
| 32 | self.assertEqual('gerrit', tenant.project_repos[0][0].name) |
| 33 | self.assertEqual('org/project', tenant.project_repos[0][1].name) |
| 34 | |
| 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) |