OLD | NEW |
(Empty) | |
| 1 import unittest |
| 2 |
| 3 import PRESUBMIT |
| 4 from presubmit_test_mocks import MockInputApi, MockOutputApi |
| 5 |
| 6 |
| 7 class CheckBugEntryField(unittest.TestCase): |
| 8 def testCommitMessageBugEntryWithNoError(self): |
| 9 mock_input_api = MockInputApi() |
| 10 mock_output_api = MockOutputApi() |
| 11 mock_input_api.change.BUG = 'webrtc:1234' |
| 12 errors = PRESUBMIT.CheckCommitMessageBugEntry(mock_input_api, |
| 13 mock_output_api) |
| 14 self.assertEqual(0, len(errors)) |
| 15 |
| 16 def testCommitMessageBugEntryReturnError(self): |
| 17 mock_input_api = MockInputApi() |
| 18 mock_output_api = MockOutputApi() |
| 19 mock_input_api.change.BUG = 'webrtc:1234,webrtc=4321' |
| 20 errors = PRESUBMIT.CheckCommitMessageBugEntry(mock_input_api, |
| 21 mock_output_api) |
| 22 self.assertEqual(1, len(errors)) |
| 23 self.assertEqual(('Bogus BUG entry: webrtc=4321. Please specify' |
| 24 ' the issue tracker prefix and the issue number,' |
| 25 ' separated by a colon, e.g. webrtc:123 or' |
| 26 ' chromium:12345.'), str(errors[0])) |
| 27 |
| 28 def testCommitMessageBugEntryIsNone(self): |
| 29 mock_input_api = MockInputApi() |
| 30 mock_output_api = MockOutputApi() |
| 31 mock_input_api.change.BUG = 'None' |
| 32 errors = PRESUBMIT.CheckCommitMessageBugEntry(mock_input_api, |
| 33 mock_output_api) |
| 34 self.assertEqual(0, len(errors)) |
| 35 |
| 36 |
| 37 if __name__ == '__main__': |
| 38 unittest.main() |
| 39 |
OLD | NEW |