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

Unified Diff: tests/git_cl_test.py

Issue 2022183003: Fix & refactor git cl patch. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 7 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 82a404ccc4abed4d5f96257abafd405d6eeec24c..3924b22d948f89322c1a3af2d90858cc8a96db81 100755
--- a/tests/git_cl_test.py
+++ b/tests/git_cl_test.py
@@ -1109,14 +1109,6 @@ class TestGitCl(TestCase):
def test_patch_when_dirty(self):
# Patch when local tree is dirty
self.mock(git_common, 'is_dirty_git_tree', lambda x: True)
- self.calls = [
- ((['git', 'symbolic-ref', 'HEAD'],), 'master'),
- ((['git', 'config', 'branch.master.rietveldissue'],), ''),
- ((['git', 'config', 'branch.master.gerritissue'],), ''),
- ((['git', 'config', 'rietveld.autoupdate'],), ''),
- ((['git', 'config', 'gerrit.host'],), ''),
- ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'),
- ]
self.assertNotEqual(git_cl.main(['patch', '123456']), 0)
def test_diff_when_dirty(self):
@@ -1154,16 +1146,15 @@ class TestGitCl(TestCase):
lambda *args: 'Description')
self.mock(git_cl, 'IsGitVersionAtLeast', lambda *args: True)
+ self.calls = self.calls or []
if not force_codereview:
# These calls detect codereview to use.
- self.calls = [
+ self.calls += [
((['git', 'symbolic-ref', 'HEAD'],), 'master'),
((['git', 'config', 'branch.master.rietveldissue'],), ''),
((['git', 'config', 'branch.master.gerritissue'],), ''),
((['git', 'config', 'rietveld.autoupdate'],), ''),
]
- else:
- self.calls = []
if is_gerrit:
if not force_codereview:
@@ -1178,7 +1169,7 @@ class TestGitCl(TestCase):
((['sed', '-e', 's|^--- a/|--- |; s|^+++ b/|+++ |'],), ''),
]
- def test_patch_successful(self):
+ def _common_patch_successful(self):
self._patch_common()
self.calls += [
((['git', 'apply', '--index', '-p0', '--3way'],), ''),
@@ -1192,8 +1183,16 @@ class TestGitCl(TestCase):
'https://codereview.example.com'],), ''),
((['git', 'config', 'branch.master.rietveldpatchset', '60001'],), ''),
]
+
+ def test_patch_successful(self):
+ self._common_patch_successful()
self.assertEqual(git_cl.main(['patch', '123456']), 0)
+ def test_patch_successful_new_branch(self):
+ self.calls = [ ((['git', 'new-branch', 'master'],), ''), ]
+ self._common_patch_successful()
+ self.assertEqual(git_cl.main(['patch', '-b', 'master', '123456']), 0)
+
def test_patch_conflict(self):
self._patch_common()
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