blob: bb9993e71f46d0230b27c2b136ccf92ea7e945b0 [file] [log] [blame]
Jesse Keatingd96e5882017-01-19 13:55:50 -08001#!/usr/bin/env python
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
16from tests.base import ZuulTestCase, simple_layout
17
18
19class TestGithubRequirements(ZuulTestCase):
20 """Test pipeline and trigger requirements"""
21 config_file = 'zuul-github-driver.conf'
22
23 @simple_layout('layouts/requirements-github.yaml', driver='github')
24 def test_pipeline_require_status(self):
25 "Test pipeline requirement: status"
26 A = self.fake_github.openFakePullRequest('org/project1', 'master', 'A')
27 # A comment event that we will keep submitting to trigger
28 comment = A.getCommentAddedEvent('test me')
29 self.fake_github.emitEvent(comment)
30 self.waitUntilSettled()
31 # No status from zuul so should not be enqueued
32 self.assertEqual(len(self.history), 0)
33
34 # An error status should not cause it to be enqueued
35 A.setStatus(A.head_sha, 'error', 'null', 'null', 'check')
36 self.fake_github.emitEvent(comment)
37 self.waitUntilSettled()
38 self.assertEqual(len(self.history), 0)
39
40 # A success status goes in
41 A.setStatus(A.head_sha, 'success', 'null', 'null', 'check')
42 self.fake_github.emitEvent(comment)
43 self.waitUntilSettled()
44 self.assertEqual(len(self.history), 1)
45 self.assertEqual(self.history[0].name, 'project1-pipeline')