Fix ordering of tags in the OCI model
Before this change, we were neglecting to sort the tags by ID, which meant that pagination was broken
This commit is contained in:
parent
d3dd2f7b7c
commit
96072a44c0
6 changed files with 51 additions and 6 deletions
|
@ -936,3 +936,37 @@ def test_unicode_emoji(registry_model):
|
|||
assert found.digest == manifest.digest
|
||||
assert found.internal_manifest_bytes.as_encoded_str() == manifest.bytes.as_encoded_str()
|
||||
assert found.get_parsed_manifest().digest == manifest.digest
|
||||
|
||||
|
||||
def test_list_repository_tags(oci_model):
|
||||
repository_ref = oci_model.lookup_repository('devtable', 'simple')
|
||||
latest_tag = oci_model.get_repo_tag(repository_ref, 'latest')
|
||||
manifest = oci_model.get_manifest_for_tag(latest_tag)
|
||||
|
||||
tag_count = 500
|
||||
|
||||
# Create a bunch of tags.
|
||||
tags_expected = set()
|
||||
for index in range(0, tag_count):
|
||||
tags_expected.add('somenewtag%s' % index)
|
||||
oci_model.retarget_tag(repository_ref, 'somenewtag%s' % index, manifest, storage)
|
||||
|
||||
# List the tags.
|
||||
tags_found = set()
|
||||
tag_id = None
|
||||
while True:
|
||||
tags = oci_model.list_repository_tags(repository_ref, start_pagination_id=tag_id,
|
||||
limit=11, sort_tags=True)
|
||||
assert len(tags) <= 11
|
||||
for tag in tags[0:10]:
|
||||
assert tag.name not in tags_found
|
||||
if tag.name in tags_expected:
|
||||
tags_expected.remove(tag.name)
|
||||
|
||||
if len(tags) < 11:
|
||||
break
|
||||
|
||||
tag_id = tags[10].id
|
||||
|
||||
# Make sure we've found all the tags.
|
||||
assert not tags_expected
|
||||
|
|
Reference in a new issue