Skip to content

Commit

Permalink
adding draft test for tag deletion
Browse files Browse the repository at this point in the history
Signed-off-by: mjgaughan <[email protected]>
  • Loading branch information
mjgaughan committed Jul 2, 2024
1 parent 6f68f5d commit a2561b5
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand Down

0 comments on commit a2561b5

Please sign in to comment.