X-Git-Url: http://git.scottworley.com/git-cache/blobdiff_plain/35000f728e66533de9b0cf6e8b040f9cdb82c1a7..004804f0d1ef301076ea6c8a5b7d0287d096fca1:/test_git_cache.py diff --git a/test_git_cache.py b/test_git_cache.py index b7e0ede..2990f56 100644 --- a/test_git_cache.py +++ b/test_git_cache.py @@ -52,6 +52,7 @@ class TestGitCache(unittest.TestCase): os.environ['GIT_COMMITTER_EMAIL'] = 'test_git_cache@example.com' os.environ['BACKOFF_MAX_TIME'] = '0' + os.environ['FORCE_WARNING_TIME'] = '0' # ONLY FOR TEST USE! self.tempdir = tempfile.TemporaryDirectory(prefix='git_cache_test-') self.upstream = os.path.join(self.tempdir.name, 'upstream') @@ -225,6 +226,32 @@ class TestGitCache(unittest.TestCase): with self.assertRaises(Exception): git_cache.ensure_rev_available(self.upstream, 'master', rev) + def test_force_fetch_after_amend(self) -> None: + git_cache.fetch(self.upstream, 'master') + _git(self.upstream, 'commit', '--amend', '-m', 'Amended') + git_cache.fetch(self.upstream, 'master', force=True) + + def test_force_ensure_after_amend(self) -> None: + git_cache.fetch(self.upstream, 'master') + _git(self.upstream, 'commit', '--amend', '-m', 'Amended') + rev = _git(self.upstream, 'log', '--format=%H', '-n1').strip().decode() + git_cache.ensure_rev_available( + self.upstream, 'master', rev, force=True) + + def test_force_fetch_after_amend_and_cache_delete(self) -> None: + d, _ = git_cache.fetch(self.upstream, 'master') + shutil.rmtree(d) + _git(self.upstream, 'commit', '--amend', '-m', 'Amended') + git_cache.fetch(self.upstream, 'master', force=True) + + def test_force_ensure_after_amend_and_cache_delete(self) -> None: + d, _ = git_cache.fetch(self.upstream, 'master') + shutil.rmtree(d) + _git(self.upstream, 'commit', '--amend', '-m', 'Amended') + rev = _git(self.upstream, 'log', '--format=%H', '-n1').strip().decode() + git_cache.ensure_rev_available( + self.upstream, 'master', rev, force=True) + if __name__ == '__main__': unittest.main()