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

Unified Diff: tests/git_footers_test.py

Issue 2028303006: Refactor git_footers for later use in git cl. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@footer
Patch Set: nit 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « git_footers.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/git_footers_test.py
diff --git a/tests/git_footers_test.py b/tests/git_footers_test.py
index 23ca473637f883f10360567db721caee6fca6214..28f9916548d12101d74214b9ddd22fcf1636087e 100755
--- a/tests/git_footers_test.py
+++ b/tests/git_footers_test.py
@@ -35,9 +35,18 @@ My commit message is my best friend. It is my life. I must master it.
_git_svn_id_footer_branch = 'git-svn-id: %s\n' % _git_svn_id_branch
-
def testFootersBasic(self):
self.assertEqual(
+ git_footers.split_footers('Not-A: footer'),
+ (['Not-A: footer'], [], []))
+ self.assertEqual(
+ git_footers.split_footers('Header\n\nActual: footer'),
+ (['Header', ''], ['Actual: footer'], [('Actual', 'footer')]))
+ self.assertEqual(
+ git_footers.split_footers('\nActual: footer'),
+ ([''], ['Actual: footer'], [('Actual', 'footer')]))
+
+ self.assertEqual(
git_footers.parse_footers(self._message), {})
self.assertEqual(
git_footers.parse_footers(self._message + self._position_footer),
@@ -82,6 +91,9 @@ My commit message is my best friend. It is my life. I must master it.
'desc\nBUG=not-a-valid-footer\n\nChange-Id: Ixxx'))
def testAddFooterChangeId(self):
+ with self.assertRaises(AssertionError):
+ git_footers.add_footer_change_id('Already has\n\nChange-Id: Ixxx', 'Izzz')
+
self.assertEqual(
git_footers.add_footer_change_id('header-only', 'Ixxx'),
'header-only\n\nChange-Id: Ixxx')
@@ -107,6 +119,33 @@ My commit message is my best friend. It is my life. I must master it.
git_footers.add_footer_change_id('header: like footer', 'Ixxx'),
'header: like footer\n\nChange-Id: Ixxx')
+ def testAddFooter(self):
+ self.assertEqual(
+ git_footers.add_footer('', 'Key', 'Value'),
+ '\nKey: Value')
+ self.assertEqual(
+ git_footers.add_footer('Header with empty line.\n\n', 'Key', 'Value'),
+ 'Header with empty line.\n\nKey: Value')
+
+ self.assertEqual(
+ git_footers.add_footer('Top\n\nSome: footer', 'Key', 'value'),
+ 'Top\n\nSome: footer\nKey: value')
+
+ self.assertEqual(
+ git_footers.add_footer('Top\n\nSome: footer', 'Key', 'value',
+ after_keys=['Any']),
+ 'Top\n\nKey: value\nSome: footer')
+
+ self.assertEqual(
+ git_footers.add_footer('Top\n\nSome: footer', 'Key', 'value',
+ after_keys=['Some']),
+ 'Top\n\nSome: footer\nKey: value')
+
+ self.assertEqual(
+ git_footers.add_footer('Top\n\nSome: footer\nOther: footer',
+ 'Key', 'value', after_keys=['Some']),
+ 'Top\n\nSome: footer\nKey: value\nOther: footer')
+
def testReadStdin(self):
self.mock(git_footers.sys, 'stdin', StringIO.StringIO(
'line\r\notherline\r\n\r\n\r\nFoo: baz'))
« no previous file with comments | « git_footers.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698