def test_delete_tags_for_manifest_same_manifest(initialized_db): new_repo = model.repository.create_repository("devtable", "newrepo", None) manifest_1, _ = create_manifest_for_testing(new_repo, "1") manifest_2, _ = create_manifest_for_testing(new_repo, "2") assert manifest_1.digest != manifest_2.digest # Add some tag history, moving a tag back and forth between two manifests. retarget_tag("latest", manifest_1) retarget_tag("latest", manifest_2) retarget_tag("latest", manifest_1) retarget_tag("latest", manifest_2) retarget_tag("another1", manifest_1) retarget_tag("another2", manifest_2) # Delete all tags pointing to the first manifest. delete_tags_for_manifest(manifest_1) assert get_tag(new_repo, "latest").manifest == manifest_2 assert get_tag(new_repo, "another1") is None assert get_tag(new_repo, "another2").manifest == manifest_2 # Delete all tags pointing to the second manifest, which should actually delete the `latest` # tag now. delete_tags_for_manifest(manifest_2) assert get_tag(new_repo, "latest") is None assert get_tag(new_repo, "another1") is None assert get_tag(new_repo, "another2") is None
def test_delete_tags_for_manifest(initialized_db): for tag in list(filter_to_visible_tags(filter_to_alive_tags(Tag.select()))): repo = tag.repository assert get_tag(repo, tag.name) == tag with assert_query_count(4): assert delete_tags_for_manifest(tag.manifest) == [tag] assert get_tag(repo, tag.name) is None