OLD | NEW |
---|---|
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 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1293 'press Enter to continue, Ctrl+C to abort.'],), '')) | 1293 'press Enter to continue, Ctrl+C to abort.'],), '')) |
1294 self.assertIsNone(cl.EnsureAuthenticated(force=False)) | 1294 self.assertIsNone(cl.EnsureAuthenticated(force=False)) |
1295 | 1295 |
1296 def test_gerrit_ensure_authenticated_ok(self): | 1296 def test_gerrit_ensure_authenticated_ok(self): |
1297 cl = self._test_gerrit_ensure_authenticated_common(auth={ | 1297 cl = self._test_gerrit_ensure_authenticated_common(auth={ |
1298 'chromium.googlesource.com': 'same', | 1298 'chromium.googlesource.com': 'same', |
1299 'chromium-review.googlesource.com': 'same', | 1299 'chromium-review.googlesource.com': 'same', |
1300 }) | 1300 }) |
1301 self.assertIsNone(cl.EnsureAuthenticated(force=False)) | 1301 self.assertIsNone(cl.EnsureAuthenticated(force=False)) |
1302 | 1302 |
1303 def test_cmd_set_commit_rietveld(self): | |
1304 self.mock(git_cl._RietveldChangelistImpl, 'SetFlag', | |
1305 lambda _, f, v: self._mocked_call(['SetFlag', f, v])) | |
1306 self.calls = [ | |
1307 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'), | |
1308 ((['git', 'config', 'branch.feature.rietveldissue'],), '123'), | |
1309 ((['git', 'config', 'rietveld.autoupdate'],), ''), | |
1310 ((['git', 'config', 'rietveld.server'],), ''), | |
1311 ((['git', 'config', 'rietveld.server'],), ''), | |
1312 ((['git', 'config', 'branch.feature.rietveldserver'],), | |
1313 'https://codereview.chromium.org'), | |
1314 ((['SetFlag', 'commit', '1'], ), ''), | |
1315 ] | |
1316 self.assertEqual(0, git_cl.main(['set-commit'])) | |
Sergiy Byelozyorov
2016/04/13 17:15:03
also need a test for dry-run here
tandrii(chromium)
2016/04/13 17:17:16
see above - don't care about dry-run.
| |
1317 | |
1318 def test_cmd_set_commit_gerrit(self): | |
1319 self.mock(git_cl.gerrit_util, 'SetReview', | |
1320 lambda h, i, labels: self._mocked_call( | |
1321 ['SetReview', h, i, labels])) | |
1322 self.calls = [ | |
1323 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'), | |
1324 ((['git', 'config', 'branch.feature.rietveldissue'],), ''), | |
1325 ((['git', 'config', 'branch.feature.gerritissue'],), '123'), | |
1326 ((['git', 'config', 'branch.feature.gerritserver'],), | |
1327 'https://chromium-review.googlesource.com'), | |
1328 ((['SetReview', 'chromium-review.googlesource.com', 123, | |
1329 {'Commit-Queue': 1}],), ''), | |
1330 ] | |
1331 self.assertEqual(0, git_cl.main(['set-commit', '-d'])) | |
Sergiy Byelozyorov
2016/04/13 17:15:03
do you test non-dry-run scenario?
tandrii(chromium)
2016/04/13 17:17:16
no, it's same codepath.
| |
1332 | |
1303 | 1333 |
1304 if __name__ == '__main__': | 1334 if __name__ == '__main__': |
1305 git_cl.logging.basicConfig( | 1335 git_cl.logging.basicConfig( |
1306 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 1336 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
1307 unittest.main() | 1337 unittest.main() |
OLD | NEW |