From a2561b55a2e7f7cee4c5ad8333b3cc44666b8ae0 Mon Sep 17 00:00:00 2001 From: mjgaughan Date: Mon, 1 Jul 2024 23:23:11 -0400 Subject: [PATCH] adding draft test for tag deletion Signed-off-by: mjgaughan --- tests/test_git.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/test_git.py b/tests/test_git.py index f3b17f107..4614120dd 100644 --- a/tests/test_git.py +++ b/tests/test_git.py @@ -1799,7 +1799,52 @@ def test_sync(self): # Cleanup shutil.rmtree(editable_path) shutil.rmtree(new_path) + + def test_tag_removal_sync(self): + """Test sync process for tag removal""" + origin_path = os.path.join(self.tmp_repo_path, 'gittest') + editable_path = os.path.join(self.tmp_path, 'editgit') + new_path = os.path.join(self.tmp_path, 'newgit') + + shutil.copytree(origin_path, editable_path) + + repo = GitRepository.clone(editable_path, new_path) + repo.sync() + + #Add a tag 'v.0.0-lw' to the refs and check that it exists + cmd = ['git', 'tag', 'v.0.0-lw'] + subprocess.check_output(cmd, stderr=subprocess.STDOUT, + cwd=editable_path, env={'LANG': 'C'}) + + new_commits = repo.sync() + self.assertEqual(len(new_commits), 0) + + expected = [ + 'refs/heads/master', + 'refs/tags/v.0.0-lw' + ] + refs = [ref for ref in discover_refs(new_path).keys()] + refs.sort() + self.assertListEqual(refs, expected) + + #Delete the tag 'v.0.0-lw' and check that it has been deleted from refs + cmd = ['git', 'tag', '-d', 'v.0.0-lw'] + subprocess.check_output(cmd, stderr=subprocess.STDOUT, + cwd=editable_path, env={'LANG': 'C'}) + + new_commits = repo.sync() + self.assertEqual(len(new_commits), 0) + expected = [ + 'refs/heads/master' + ] + refs = [ref for ref in discover_refs(new_path).keys()] + refs.sort() + self.assertListEqual(refs, expected) + #Cleanup + shutil.rmtree(editable_path) + shutil.rmtree(new_path) + def test_sync_from_empty_repos(self): """Test sync process on empty repositories"""