Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: PRESUBMIT_test.py

Issue 3010153002: PRESUBMIT: Enforce tracker prefix for all BUG entries (Closed)
Patch Set: Added in test directory Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « PRESUBMIT.py ('k') | PRESUBMIT_test_mocks.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT_test.py
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..7157b775d75686cda64fad626ba86fff2702461b
--- /dev/null
+++ b/PRESUBMIT_test.py
@@ -0,0 +1,43 @@
+import unittest
+
+import PRESUBMIT
+from PRESUBMIT_test_mocks import MockInputApi, MockOutputApi
+
+
+class CheckBugEntryField(unittest.TestCase):
+ def testCommitMessageBugEntryWithNoError(self):
+ mock_input_api = MockInputApi()
+ mock_output_api = MockOutputApi()
+ mock_input_api.change.BUG = 'webrtc:1234'
+ errors = PRESUBMIT._CheckCommitMessageBugEntry(mock_input_api,
+ mock_output_api)
+ self.assertEqual(0, len(errors))
+
+ def testCommitMessageBugEntryReturnError(self):
+ mock_input_api = MockInputApi()
+ mock_output_api = MockOutputApi()
+ mock_input_api.change.BUG = 'webrtc:1234,webrtc=4321'
+ errors = PRESUBMIT._CheckCommitMessageBugEntry(mock_input_api,
+ mock_output_api)
+ self.assertEqual(1, len(errors))
+ self.assertEqual(('Bogus BUG entry: webrtc=4321. Please specify'
+ ' the issue tracker prefix and the issue number,'
+ ' separated by a colon, e.g. webrtc:123 or'
+ ' chromium:12345.'), str(errors[0]))
+
+ def testCommitMessageButEntryReturnErrorWhenBugIsNone(self):
+ mock_input_api = MockInputApi()
+ mock_output_api = MockOutputApi()
+ mock_input_api.change.BUG = None
+ errors = PRESUBMIT._CheckCommitMessageBugEntry(mock_input_api,
+ mock_output_api)
+ self.assertEqual(1, len(errors))
kjellander_webrtc 2017/09/07 08:28:15 This should not be an error. we want to accept Non
charujain 2017/09/08 09:57:04 I think the code already handles this. The test wa
+ self.assertEqual(('Bogus BUG entry: . Please specify'
+ ' the issue tracker prefix and the issue number,'
+ ' separated by a colon, e.g. webrtc:123 or'
+ ' chromium:12345.'), str(errors[0]))
+
+
+if __name__ == '__main__':
+ unittest.main()
+
« no previous file with comments | « PRESUBMIT.py ('k') | PRESUBMIT_test_mocks.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698