git cl comment: implement adding comment for Gerrit.
BUG=698236
Change-Id: Ia1a36af71c348be991d77083092c5043c2642c19
Reviewed-on: https://chromium-review.googlesource.com/455877
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py
index 2af3174..7d8ee6d 100755
--- a/tests/git_cl_test.py
+++ b/tests/git_cl_test.py
@@ -3089,6 +3089,34 @@
sys.stdout.getvalue(),
'However, your configured .gitcookies file is missing.')
+ def test_git_cl_comment_add_default(self):
+ self.mock(git_cl._RietveldChangelistImpl, 'AddComment',
+ lambda _, message: self._mocked_call('AddComment', message))
+ self.calls = [
+ ((['git', 'config', 'rietveld.autoupdate'],), CERR1),
+ ((['git', 'config', 'rietveld.server'],), 'codereview.chromium.org'),
+ (('AddComment', 'msg'), ''),
+ ]
+ # TODO(tandrii): --rietveld should be specified here.
+ self.assertEqual(0, git_cl.main(['comment', '-i', '10', '-a', 'msg']))
+
+ def test_git_cl_comment_add_gerrit(self):
+ self.mock(git_cl.gerrit_util, 'SetReview',
+ lambda host, change, msg:
+ self._mocked_call('SetReview', host, change, msg))
+ self.calls = [
+ ((['git', 'symbolic-ref', 'HEAD'],), CERR1),
+ ((['git', 'symbolic-ref', 'HEAD'],), CERR1),
+ ((['git', 'config', 'rietveld.upstream-branch'],), CERR1),
+ ((['git', 'branch', '-r'],), 'origin/HEAD -> origin/master\n'
+ 'origin/master'),
+ ((['git', 'config', 'remote.origin.url'],),
+ 'https://chromium.googlesource.com/infra/infra'),
+ (('SetReview', 'chromium-review.googlesource.com', 10, 'msg'), None),
+ ]
+ self.assertEqual(0, git_cl.main(['comment', '--gerrit', '-i', '10',
+ '-a', 'msg']))
+
if __name__ == '__main__':
logging.basicConfig(