OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 |
| 3 """Tests for git_footers.""" |
| 4 |
| 5 import os |
| 6 import sys |
| 7 import unittest |
| 8 |
| 9 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| 10 |
| 11 import git_footers |
| 12 |
| 13 class GitFootersTest(unittest.TestCase): |
| 14 _message = """ |
| 15 This is my commit message. There are many like it, but this one is mine. |
| 16 |
| 17 My commit message is my best friend. It is my life. I must master it. |
| 18 |
| 19 """ |
| 20 |
| 21 _position = 'refs/heads/master@{#292272}' |
| 22 |
| 23 _position_footer = 'Cr-Commit-Position: %s\n' % _position |
| 24 |
| 25 _git_svn_id = ('svn://svn.chromium.org/chrome/trunk/src@290386' |
| 26 ' 0039d316-1c4b-4281-b951-d872f2087c98') |
| 27 |
| 28 _git_svn_id_footer = 'git-svn-id: %s\n' % _git_svn_id |
| 29 |
| 30 _git_svn_id_branch = ( |
| 31 'svn://svn.chromium.org/chrome/branches/blabble/src@177288') |
| 32 |
| 33 _git_svn_id_footer_branch = 'git-svn-id: %s\n' % _git_svn_id_branch |
| 34 |
| 35 |
| 36 def testFootersBasic(self): |
| 37 self.assertEqual( |
| 38 git_footers.parse_footers(self._message), {}) |
| 39 self.assertEqual( |
| 40 git_footers.parse_footers(self._message + self._position_footer), |
| 41 { 'Cr-Commit-Position': [ self._position ] }) |
| 42 self.assertEqual( |
| 43 git_footers.parse_footers(self._message + self._git_svn_id_footer), |
| 44 { 'Git-Svn-Id': [ self._git_svn_id ] }) |
| 45 self.assertEqual( |
| 46 git_footers.parse_footers(self._message + self._position_footer |
| 47 + self._position_footer), |
| 48 { 'Cr-Commit-Position': [ self._position, self._position ] }) |
| 49 |
| 50 def testTrunkHeuristic(self): |
| 51 footers = git_footers.parse_footers(self._message + self._git_svn_id_footer) |
| 52 self.assertEqual( |
| 53 footers, |
| 54 { 'Git-Svn-Id': [ self._git_svn_id ] }) |
| 55 self.assertEqual( |
| 56 git_footers.get_position(footers), |
| 57 ('refs/heads/master', '290386')) |
| 58 |
| 59 def testBranchHeuristic(self): |
| 60 footers = git_footers.parse_footers(self._message + |
| 61 self._git_svn_id_footer_branch) |
| 62 self.assertEqual( |
| 63 footers, |
| 64 { 'Git-Svn-Id': [ self._git_svn_id_branch ] }) |
| 65 self.assertEqual( |
| 66 git_footers.get_position(footers), |
| 67 ('refs/branch-heads/blabble', None)) |
| 68 |
| 69 if __name__ == '__main__': |
| 70 unittest.main() |
OLD | NEW |