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

Unified Diff: tests/git_cl_test.py

Issue 1880243003: git cl: add --gerrit and --rietveld options to force codereview. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@T200
Patch Set: Created 4 years, 8 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 | « git_cl.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/git_cl_test.py
diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py
index 8eacfbbfe73e4ee28ccac82dd563897a69acae3b..295d1a0fb62f7f073a6099d8e4c9a8818e884759 100755
--- a/tests/git_cl_test.py
+++ b/tests/git_cl_test.py
@@ -1093,7 +1093,7 @@ class TestGitCl(TestCase):
self.mock(git_common, 'is_dirty_git_tree', lambda x: True)
self.assertNotEqual(git_cl.main(['diff']), 0)
- def _patch_common(self, is_gerrit=False):
+ def _patch_common(self, is_gerrit=False, force_codereview=False):
self.mock(git_cl._RietveldChangelistImpl, 'GetMostRecentPatchset',
lambda x: '60001')
self.mock(git_cl._RietveldChangelistImpl, 'GetPatchSetDiff',
@@ -1122,17 +1122,23 @@ class TestGitCl(TestCase):
lambda *args: 'Description')
self.mock(git_cl, 'IsGitVersionAtLeast', lambda *args: True)
- self.calls = [
- ((['git', 'symbolic-ref', 'HEAD'],), 'master'),
- ((['git', 'config', 'branch.master.rietveldissue'],), ''),
- ((['git', 'config', 'branch.master.gerritissue'],), ''),
- ((['git', 'config', 'rietveld.autoupdate'],), ''),
- ]
- if is_gerrit:
- self.calls += [
- ((['git', 'config', 'gerrit.host'],), 'true'),
+ if not force_codereview:
+ # These calls detect codereview to use.
+ self.calls = [
+ ((['git', 'symbolic-ref', 'HEAD'],), 'master'),
+ ((['git', 'config', 'branch.master.rietveldissue'],), ''),
tandrii(chromium) 2016/04/13 18:13:46 if this line had '12345' at the end, it'd tell git
+ ((['git', 'config', 'branch.master.gerritissue'],), ''),
+ ((['git', 'config', 'rietveld.autoupdate'],), ''),
]
else:
+ self.calls = []
+
+ if is_gerrit:
+ if not force_codereview:
+ self.calls += [
+ ((['git', 'config', 'gerrit.host'],), 'true'),
+ ]
+ else:
self.calls += [
((['git', 'config', 'gerrit.host'],), ''),
((['git', 'config', 'rietveld.server'],), 'codereview.example.com'),
@@ -1182,6 +1188,25 @@ class TestGitCl(TestCase):
]
self.assertEqual(git_cl.main(['patch', '123456']), 0)
+ def test_patch_force_codereview(self):
+ self._patch_common(is_gerrit=True, force_codereview=True)
Sergiy Byelozyorov 2016/04/13 17:18:59 can you please try to create mock rietveld CL here
tandrii(chromium) 2016/04/13 18:13:46 Ha, good comment/idea! However, the calls below is
Sergiy Byelozyorov 2016/04/13 18:21:55 Acknowledged.
+ self.calls += [
+ ((['git', 'fetch', 'https://chromium.googlesource.com/my/repo',
+ 'refs/changes/56/123456/7'],), ''),
+ ((['git', 'cherry-pick', 'FETCH_HEAD'],), ''),
+ ((['git', 'symbolic-ref', 'HEAD'],), 'master'),
+ ((['git', 'config', 'branch.master.gerritissue', '123456'],), ''),
+ ((['git', 'config', 'branch.master.gerritserver'],), ''),
+ ((['git', 'config', 'branch.master.merge'],), 'master'),
+ ((['git', 'config', 'branch.master.remote'],), 'origin'),
+ ((['git', 'config', 'remote.origin.url'],),
+ 'https://chromium.googlesource.com/my/repo'),
+ ((['git', 'config', 'branch.master.gerritserver',
+ 'https://chromium-review.googlesource.com'],), ''),
+ ((['git', 'config', 'branch.master.gerritpatchset', '7'],), ''),
+ ]
+ self.assertEqual(git_cl.main(['patch', '--gerrit', '123456']), 0)
+
def test_gerrit_patch_url_successful(self):
self._patch_common(is_gerrit=True)
self.calls += [
« no previous file with comments | « git_cl.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698