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

Unified Diff: tests/git_cl_test.py

Issue 2276663002: git cl archive: Add "--dry-run" and "--notags" flags. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 4 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 f2c05a0d088288c0ba0dab7a649342c9d3e8a695..afa3b58bc9d21a7ca4ceeac9f964fec24ce2c76c 100755
--- a/tests/git_cl_test.py
+++ b/tests/git_cl_test.py
@@ -1743,6 +1743,69 @@ class TestGitCl(TestCase):
self.assertEqual(1, git_cl.main(['archive', '-f']))
+ def test_archive_dry_run(self):
+ self.mock(git_cl.sys, 'stdout', StringIO.StringIO())
+
+ self.calls = \
+ [((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'],),
+ 'refs/heads/master\nrefs/heads/foo\nrefs/heads/bar'),
+ ((['git', 'config', 'branch.master.rietveldissue'],), '1'),
+ ((['git', 'config', 'rietveld.autoupdate'],), CERR1),
+ ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'),
+ ((['git', 'config', 'branch.foo.rietveldissue'],), '456'),
+ ((['git', 'config', 'branch.bar.rietveldissue'],), CERR1),
+ ((['git', 'config', 'branch.bar.gerritissue'],), '789'),
+ ((['git', 'symbolic-ref', 'HEAD'],), 'master'),]
+
+ class MockChangelist():
tandrii(chromium) 2016/08/23 18:41:49 this thing is being copy-pasted in this file like
+ def __init__(self, branch, issue):
+ self.branch = branch
+ self.issue = issue
+ def GetBranch(self):
+ return self.branch
+ def GetIssue(self):
+ return self.issue
+
+ self.mock(git_cl, 'get_cl_statuses',
+ lambda branches, fine_grained, max_processes:
+ [(MockChangelist('master', 1), 'open'),
+ (MockChangelist('foo', 456), 'closed'),
+ (MockChangelist('bar', 789), 'open')])
+
+ self.assertEqual(0, git_cl.main(['archive', '-f', '--dry-run']))
+
+ def test_archive_no_tags(self):
+ self.mock(git_cl.sys, 'stdout', StringIO.StringIO())
+
+ self.calls = \
+ [((['git', 'for-each-ref', '--format=%(refname)', 'refs/heads'],),
+ 'refs/heads/master\nrefs/heads/foo\nrefs/heads/bar'),
+ ((['git', 'config', 'branch.master.rietveldissue'],), '1'),
+ ((['git', 'config', 'rietveld.autoupdate'],), CERR1),
+ ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'),
+ ((['git', 'config', 'branch.foo.rietveldissue'],), '456'),
+ ((['git', 'config', 'branch.bar.rietveldissue'],), CERR1),
+ ((['git', 'config', 'branch.bar.gerritissue'],), '789'),
+ ((['git', 'symbolic-ref', 'HEAD'],), 'master'),
+ ((['git', 'branch', '-D', 'foo'],), '')]
+
+ class MockChangelist():
+ def __init__(self, branch, issue):
+ self.branch = branch
+ self.issue = issue
+ def GetBranch(self):
+ return self.branch
+ def GetIssue(self):
+ return self.issue
+
+ self.mock(git_cl, 'get_cl_statuses',
+ lambda branches, fine_grained, max_processes:
+ [(MockChangelist('master', 1), 'open'),
+ (MockChangelist('foo', 456), 'closed'),
+ (MockChangelist('bar', 789), 'open')])
+
+ self.assertEqual(0, git_cl.main(['archive', '-f', '--notags']))
+
def test_cmd_issue_erase_existing(self):
out = StringIO.StringIO()
self.mock(git_cl.sys, 'stdout', out)
« 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