diff options
author | Jeremy Stanley <fungi@yuggoth.org> | 2021-02-24 20:22:05 +0000 |
---|---|---|
committer | Jeremy Stanley <fungi@yuggoth.org> | 2021-02-26 16:20:41 +0000 |
commit | e8d54043203fd80a28a437684fed8ab3b24a3b21 (patch) | |
tree | 81df4cd1c7e2522388ca6f47992e3803e0ddc6ad | |
parent | c1b1e6cbfe5a6bcb2b851eb0ae3ee1ace8f41da6 (diff) | |
download | git-review-e8d54043203fd80a28a437684fed8ab3b24a3b21.tar.gz |
Add test helpers for unstaged/uncommitted changes
In order to better test detection of unstaged and uncommitted
changes, add base test methods to create changes and not stage or
commit them, ensuring they can result in an unstaged diff or staged
but uncommitted edits. To ensure that these work, use them within
the simple change creation method to perform the actual file edit.
Change-Id: Ib698d0057a404f073490d1683a8eef8d0c143122
-rw-r--r-- | git_review/tests/__init__.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/git_review/tests/__init__.py b/git_review/tests/__init__.py index 8652d42..3393940 100644 --- a/git_review/tests/__init__.py +++ b/git_review/tests/__init__.py @@ -313,13 +313,25 @@ class BaseGitReviewTestCase(testtools.TestCase, GerritHelpers): utils.run_cmd(gerrit_sh, 'start') self.addCleanup(utils.run_cmd, gerrit_sh, 'stop') - def _simple_change(self, change_text, commit_message, - file_=None): - """Helper method to create small changes and commit them.""" + def _unstaged_change(self, change_text, file_=None): + """Helper method to create small changes and not stage them.""" if file_ is None: file_ = self._dir('test', 'test_file.txt') + utils.write_to_file(file_, ''.encode()) + self._run_git('add', file_) utils.write_to_file(file_, change_text.encode()) + + def _uncommitted_change(self, change_text, file_=None): + """Helper method to create small changes and not commit them.""" + if file_ is None: + file_ = self._dir('test', 'test_file.txt') + self._unstaged_change(change_text, file_) self._run_git('add', file_) + + def _simple_change(self, change_text, commit_message, + file_=None): + """Helper method to create small changes and commit them.""" + self._uncommitted_change(change_text, file_) self._run_git('commit', '-m', commit_message) def _simple_amend(self, change_text, file_=None): |