]> git.scottworley.com Git - git-cache/blobdiff - test_git_cache.py
Appease linter: Remove stray whitespace
[git-cache] / test_git_cache.py
index b7e0edeb149ff4d478d85f235f0ff7ed1ae17e3f..2990f56d50d35cbea956da36237c9967003e3199 100644 (file)
@@ -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['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')
 
         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)
 
         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()
 
 if __name__ == '__main__':
     unittest.main()