Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @generate_skip_decorator(GitCommitBear)
- class FakeGitHubMergeCommitBear(unittest.TestCase):
- def run_uut(self, *args, **kwargs):
- """
- Runs the unit-under-test (via `self.uut.run()`) and collects the
- messages of the yielded results as a list.
- :param args: Positional arguments to forward to the run function.
- :param kwargs: Keyword arguments to forward to the run function.
- :return: A list of the message strings.
- """
- return list(result.message for result in self.uut.run(*args, **kwargs))
- def setUp(self):
- self.msg_queue = Queue()
- self.section = Section('')
- self.uut = GitCommitBear(None, self.section, self.msg_queue)
- self._old_cwd = os.getcwd()
- self.gitdir = mkdtemp()
- os.chdir(self.gitdir)
- GitCommitBearTest.run_git_command('init')
- GitCommitBearTest.run_git_command('config', 'user.email coala@coala.io')
- GitCommitBearTest.run_git_command('config', 'user.name coala')
- def test_github_PR_merge_commit_offline(self):
- run_shell_command('echo "a" >> testfile1.txt')
- run_shell_command('git add testfile1.txt')
- run_shell_command('git commit -m "First commit"')
- commit_hash1, _ = run_shell_command('git rev-parse HEAD')
- commit_hash1 = commit_hash1.strip('\n')
- run_shell_command('git checkout -b feature-branch1')
- run_shell_command('echo "b" >> testfile2.txt')
- run_shell_command('git add testfile2.txt')
- run_shell_command('git commit -m "Second commit"')
- commit_hash2, _ = run_shell_command('git rev-parse HEAD')
- commit_hash2 = commit_hash2.strip('\n')
- run_shell_command('git checkout master')
- run_shell_command('git merge --no-ff feature-branch1')
- command = 'git commit --amend -m ' + '\"Merge ' + commit_hash1 + ' into ' + commit_hash2 + '\"'
- run_shell_command(command)
- self.assertEqual(self.run_uut(), [])
- run_shell_command('echo "c" >> testfile3.txt ')
- run_shell_command('git add testfile3.txt')
- run_shell_command('git commit -m "Adding First commit"')
- commit_hash1, _ = run_shell_command('git rev-parse HEAD')
- commit_hash1 = commit_hash1.strip('\n')
- run_shell_command('git checkout -b feature-branch2')
- run_shell_command('echo "d" >> testfile4.txt ')
- run_shell_command('git add testfile4.txt')
- run_shell_command('git commit -m "Second commit"')
- commit_hash2, _ = run_shell_command('git rev-parse HEAD')
- commit_hash2 = commit_hash2.strip('\n')
- run_shell_command('git checkout master')
- run_shell_command('git merge --no-ff feature-branch2')
- command = 'git commit --amend -m ' + '\"Merge ' + commit_hash1 + ' into ' + commit_hash2 + '\"'
- run_shell_command(command)
- self.assertEqual(self.run_uut(), [])
Add Comment
Please, Sign In to add comment