Fix default merge failure reports
Commit 385d11e2eddad010dd8de2989668092249acddd3 moved the logic
that performs report formatting into the reporters themselves. But
it also contained a logic change to the formatting.
Previously, if an item was not mergeable, it was reported without
a job list, regardless if the merge-failure or standard failure
reporter was used. With that change, if a pipeline specified a
merge-failure message reporter, it would not format the job list,
but if no merge-failure reporter was supplied, and the standard
failure reporter was used, the standard failure reporter would not
check whether a merge-failure happened and instead always try to
format the job list.
Change-Id: If65d4f64d6558a544d3d0c2cc0b32ad7786a6bcd
diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py
index 8960e3a..81c2948 100755
--- a/tests/test_scheduler.py
+++ b/tests/test_scheduler.py
@@ -3477,6 +3477,31 @@
self.assertEqual('The merge failed! For more information...',
self.smtp_messages[0]['body'])
+ def test_default_merge_failure_reports(self):
+ """Check that the default merge failure reports are correct."""
+
+ # A should report success, B should report merge failure.
+ A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
+ A.addPatchset(['conflict'])
+ B = self.fake_gerrit.addFakeChange('org/project', 'master', 'B')
+ B.addPatchset(['conflict'])
+ A.addApproval('CRVW', 2)
+ B.addApproval('CRVW', 2)
+ self.fake_gerrit.addEvent(A.addApproval('APRV', 1))
+ self.fake_gerrit.addEvent(B.addApproval('APRV', 1))
+ self.waitUntilSettled()
+
+ self.assertEqual(3, len(self.history)) # A jobs
+ self.assertEqual(A.reported, 2)
+ self.assertEqual(B.reported, 2)
+ self.assertEqual(A.data['status'], 'MERGED')
+ self.assertEqual(B.data['status'], 'NEW')
+ self.assertIn('Build succeeded', A.messages[1])
+ self.assertIn('Merge Failed', B.messages[1])
+ self.assertIn('automatically merged', B.messages[1])
+ self.assertNotIn('logs.example.com', B.messages[1])
+ self.assertNotIn('SKIPPED', B.messages[1])
+
def test_swift_instructions(self):
"Test that the correct swift instructions are sent to the workers"
self.config.set('zuul', 'layout_config',