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

Side by Side Diff: tests/git_cl_test.py

Issue 2141283002: Fix git cl set-commit --clear. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: fix Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « git_cl.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unit tests for git_cl.py.""" 6 """Unit tests for git_cl.py."""
7 7
8 import os 8 import os
9 import StringIO 9 import StringIO
10 import stat 10 import stat
(...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 ((['git', 'config', 'branch.feature.rietveldissue'],), '123'), 1473 ((['git', 'config', 'branch.feature.rietveldissue'],), '123'),
1474 ((['git', 'config', 'rietveld.autoupdate'],), ''), 1474 ((['git', 'config', 'rietveld.autoupdate'],), ''),
1475 ((['git', 'config', 'rietveld.server'],), ''), 1475 ((['git', 'config', 'rietveld.server'],), ''),
1476 ((['git', 'config', 'rietveld.server'],), ''), 1476 ((['git', 'config', 'rietveld.server'],), ''),
1477 ((['git', 'config', 'branch.feature.rietveldserver'],), 1477 ((['git', 'config', 'branch.feature.rietveldserver'],),
1478 'https://codereview.chromium.org'), 1478 'https://codereview.chromium.org'),
1479 ((['SetFlag', 'commit', '1'], ), ''), 1479 ((['SetFlag', 'commit', '1'], ), ''),
1480 ] 1480 ]
1481 self.assertEqual(0, git_cl.main(['set-commit'])) 1481 self.assertEqual(0, git_cl.main(['set-commit']))
1482 1482
1483 def test_cmd_set_commit_gerrit(self): 1483 def _cmd_set_commit_gerrit_common(self, vote):
1484 self.mock(git_cl.gerrit_util, 'SetReview', 1484 self.mock(git_cl.gerrit_util, 'SetReview',
1485 lambda h, i, labels: self._mocked_call( 1485 lambda h, i, labels: self._mocked_call(
1486 ['SetReview', h, i, labels])) 1486 ['SetReview', h, i, labels]))
1487 self.calls = [ 1487 self.calls = [
1488 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'), 1488 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'),
1489 ((['git', 'config', 'branch.feature.rietveldissue'],), ''), 1489 ((['git', 'config', 'branch.feature.rietveldissue'],), ''),
1490 ((['git', 'config', 'branch.feature.gerritissue'],), '123'), 1490 ((['git', 'config', 'branch.feature.gerritissue'],), '123'),
1491 ((['git', 'config', 'branch.feature.gerritserver'],), 1491 ((['git', 'config', 'branch.feature.gerritserver'],),
1492 'https://chromium-review.googlesource.com'), 1492 'https://chromium-review.googlesource.com'),
1493 ((['SetReview', 'chromium-review.googlesource.com', 123, 1493 ((['SetReview', 'chromium-review.googlesource.com', 123,
1494 {'Commit-Queue': 1}],), ''), 1494 {'Commit-Queue': vote}],), ''),
1495 ] 1495 ]
1496 # TODO(tandrii): consider testing just set-commit and set-commit --clear, 1496
1497 # but without copy-pasting tons of expectations, as modifying them later is 1497 def test_cmd_set_commit_gerrit_clear(self):
1498 # super tedious. 1498 self._cmd_set_commit_gerrit_common(0)
1499 self.assertEqual(0, git_cl.main(['set-commit', '-c']))
1500
1501 def test_cmd_set_commit_gerrit_dry(self):
1502 self._cmd_set_commit_gerrit_common(1)
1499 self.assertEqual(0, git_cl.main(['set-commit', '-d'])) 1503 self.assertEqual(0, git_cl.main(['set-commit', '-d']))
1500 1504
1505 def test_cmd_set_commit_gerrit(self):
1506 self._cmd_set_commit_gerrit_common(2)
1507 self.assertEqual(0, git_cl.main(['set-commit']))
1508
1501 def test_description_display(self): 1509 def test_description_display(self):
1502 out = StringIO.StringIO() 1510 out = StringIO.StringIO()
1503 self.mock(git_cl.sys, 'stdout', out) 1511 self.mock(git_cl.sys, 'stdout', out)
1504 1512
1505 self.mock(git_cl, 'Changelist', ChangelistMock) 1513 self.mock(git_cl, 'Changelist', ChangelistMock)
1506 ChangelistMock.desc = 'foo\n' 1514 ChangelistMock.desc = 'foo\n'
1507 1515
1508 self.assertEqual(0, git_cl.main(['description', '-d'])) 1516 self.assertEqual(0, git_cl.main(['description', '-d']))
1509 self.assertEqual('foo\n', out.getvalue()) 1517 self.assertEqual('foo\n', out.getvalue())
1510 1518
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],), 1710 ((['rm_file_or_tree', '/abs/git_repo_root/.git/hooks/commit-msg'],),
1703 ''), 1711 ''),
1704 ] 1712 ]
1705 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True) 1713 cl._codereview_impl._GerritCommitMsgHookCheck(offer_removal=True)
1706 1714
1707 1715
1708 if __name__ == '__main__': 1716 if __name__ == '__main__':
1709 git_cl.logging.basicConfig( 1717 git_cl.logging.basicConfig(
1710 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) 1718 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR)
1711 unittest.main() 1719 unittest.main()
OLDNEW
« 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