diff options
author | James E. Blair <jeblair@redhat.com> | 2020-02-13 11:00:14 -0800 |
---|---|---|
committer | James E. Blair <jeblair@redhat.com> | 2020-02-13 11:02:41 -0800 |
commit | d1b95639b9c6a4a277419f7c5047495608fd7dc9 (patch) | |
tree | 978a7fbb1ccf765aa7843fb3095ecbe9756b7b0a /tests/unit/test_gerrit.py | |
parent | d48be299ab25990b484f3097d0cc74622fca484a (diff) | |
download | zuul-d1b95639b9c6a4a277419f7c5047495608fd7dc9.tar.gz |
Report robot comments to gerrit
If there are line comments, we are supposed to always report them.
However, when we added support for robot comments, we didn't update
the check which determined whether to post a review. We do that
if at least one of the following is true: there is a message, there
is a label, there is a line comment. That should also be true if
there is a robot comment (since that is a form of line comment).
This updates that check and adds a test.
Change-Id: Iebd6dafd9e040b6c443ebe1ed1e2702d37804399
Diffstat (limited to 'tests/unit/test_gerrit.py')
-rw-r--r-- | tests/unit/test_gerrit.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/unit/test_gerrit.py b/tests/unit/test_gerrit.py index 7c328b09d..567a35f10 100644 --- a/tests/unit/test_gerrit.py +++ b/tests/unit/test_gerrit.py @@ -381,6 +381,46 @@ class TestChecksApi(ZuulTestCase): self.assertEqual(len(A.checks_history), 3) self.assertEqual(A.data['status'], 'NEW') + @simple_layout('layouts/gerrit-checks.yaml') + def test_config_error(self): + # Test that line comments are reported on config errors + in_repo_conf = textwrap.dedent( + """ + - project: + check: + jobs: + - bad-job + """) + file_dict = {'.zuul.yaml': in_repo_conf} + A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A', + files=file_dict) + A.setCheck('zuul:check', reset=True) + self.waitForPoll('gerrit') + self.waitUntilSettled() + + self.assertEqual(A.checks_history[0]['zuul:check']['state'], + 'NOT_STARTED') + self.assertEqual(A.checks_history[1]['zuul:check']['state'], + 'SCHEDULED') + self.assertEqual(A.checks_history[2]['zuul:check']['state'], + 'FAILED') + self.assertEqual(len(A.checks_history), 3) + comments = sorted(A.comments, key=lambda x: x['line']) + self.assertEqual(comments[0], + {'file': '.zuul.yaml', + 'line': 5, + 'message': 'Job bad-job not defined', + 'range': {'end_character': 0, + 'end_line': 5, + 'start_character': 2, + 'start_line': 2}, + 'reviewer': {'email': 'zuul@example.com', + 'name': 'Zuul', + 'username': 'jenkins'}} + ) + self.assertEqual(A.reported, 0, "no messages should be reported") + self.assertEqual(A.messages, [], "no messages should be reported") + class TestPolling(ZuulTestCase): config_file = 'zuul-gerrit-no-stream.conf' |