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

Side by Side Diff: tests/git_cl_test.py

Issue 2033783002: git cl desc: add test that shows BUG= breaking Change-Id footer. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@review-url
Patch Set: rebases Created 4 years, 6 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 | « no previous file | 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 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1436 def test_description_set_raw(self): 1436 def test_description_set_raw(self):
1437 out = StringIO.StringIO() 1437 out = StringIO.StringIO()
1438 self.mock(git_cl.sys, 'stdout', out) 1438 self.mock(git_cl.sys, 'stdout', out)
1439 1439
1440 self.mock(git_cl, 'Changelist', ChangelistMock) 1440 self.mock(git_cl, 'Changelist', ChangelistMock)
1441 self.mock(git_cl.sys, 'stdin', StringIO.StringIO('hihi')) 1441 self.mock(git_cl.sys, 'stdin', StringIO.StringIO('hihi'))
1442 1442
1443 self.assertEqual(0, git_cl.main(['description', '-n', 'hihi'])) 1443 self.assertEqual(0, git_cl.main(['description', '-n', 'hihi']))
1444 self.assertEqual('hihi', ChangelistMock.desc) 1444 self.assertEqual('hihi', ChangelistMock.desc)
1445 1445
1446 def test_description_appends_bug_line(self):
1447 current_desc = 'Some\n\nChange-Id: xxx'
1448
1449 def RunEditor(desc, _, **kwargs):
1450 self.assertEquals(
1451 '# Enter a description of the change.\n'
1452 '# This will be displayed on the codereview site.\n'
1453 '# The first line will also be used as the subject of the review.\n'
1454 '#--------------------This line is 72 characters long'
1455 '--------------------\n' +
1456 # TODO(tandrii): fix this http://crbug.com/614587.
1457 current_desc + '\n\nBUG=',
1458 desc)
1459 return current_desc + '\n\nBUG='
1460
1461 def UpdateDescriptionRemote(_, desc):
1462 # TODO(tandrii): fix this http://crbug.com/614587.
1463 self.assertEquals(desc, current_desc + '\n\nBUG=')
1464
1465 self.mock(git_cl.sys, 'stdout', StringIO.StringIO())
1466 self.mock(git_cl.Changelist, 'GetDescription',
1467 lambda *args: current_desc)
1468 self.mock(git_cl._GerritChangelistImpl, 'UpdateDescriptionRemote',
1469 UpdateDescriptionRemote)
1470 self.mock(git_cl.gclient_utils, 'RunEditor', RunEditor)
1471
1472 self.calls = [
1473 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'),
1474 ((['git', 'config', 'branch.feature.gerritissue'],), '123'),
1475 ((['git', 'config', 'rietveld.autoupdate'],), ''),
1476 ((['git', 'config', 'rietveld.bug-prefix'],), ''),
1477 ((['git', 'config', 'core.editor'],), 'vi'),
1478 ]
1479 self.assertEqual(0, git_cl.main(['description', '--gerrit']))
1480
1446 def test_description_set_stdin(self): 1481 def test_description_set_stdin(self):
1447 out = StringIO.StringIO() 1482 out = StringIO.StringIO()
1448 self.mock(git_cl.sys, 'stdout', out) 1483 self.mock(git_cl.sys, 'stdout', out)
1449 1484
1450 self.mock(git_cl, 'Changelist', ChangelistMock) 1485 self.mock(git_cl, 'Changelist', ChangelistMock)
1451 self.mock(git_cl.sys, 'stdin', StringIO.StringIO('hi \r\n\t there\n\nman')) 1486 self.mock(git_cl.sys, 'stdin', StringIO.StringIO('hi \r\n\t there\n\nman'))
1452 1487
1453 self.assertEqual(0, git_cl.main(['description', '-n', '-'])) 1488 self.assertEqual(0, git_cl.main(['description', '-n', '-']))
1454 self.assertEqual('hi\n\t there\n\nman', ChangelistMock.desc) 1489 self.assertEqual('hi\n\t there\n\nman', ChangelistMock.desc)
1455 1490
(...skipping 13 matching lines...) Expand all
1469 ((['git', 'config', '--unset', 'branch.feature.gerritsquashhash'],), 1504 ((['git', 'config', '--unset', 'branch.feature.gerritsquashhash'],),
1470 ''), 1505 ''),
1471 ] 1506 ]
1472 self.assertEqual(0, git_cl.main(['issue', '0'])) 1507 self.assertEqual(0, git_cl.main(['issue', '0']))
1473 1508
1474 1509
1475 if __name__ == '__main__': 1510 if __name__ == '__main__':
1476 git_cl.logging.basicConfig( 1511 git_cl.logging.basicConfig(
1477 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) 1512 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR)
1478 unittest.main() 1513 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698