Fix the tests for registry v2 changes.
This commit is contained in:
parent
0dc0f23c5e
commit
b998eca8e5
3 changed files with 14 additions and 4 deletions
|
@ -139,8 +139,8 @@ def get_repository_images(namespace_name, repository_name):
|
|||
def get_image_by_id(namespace_name, repository_name, docker_image_id):
|
||||
image = get_repo_image_extended(namespace_name, repository_name, docker_image_id)
|
||||
if not image:
|
||||
raise DataModelException('Unable to find image \'%s\' for repo \'%s/%s\'' %
|
||||
(docker_image_id, namespace_name, repository_name))
|
||||
raise InvalidImageException('Unable to find image \'%s\' for repo \'%s/%s\'' %
|
||||
(docker_image_id, namespace_name, repository_name))
|
||||
return image
|
||||
|
||||
|
||||
|
|
|
@ -383,7 +383,11 @@ def get_image_ancestry(namespace, repository, image_id, headers):
|
|||
if not permission.can() and not model.repository.repository_is_public(namespace, repository):
|
||||
abort(403)
|
||||
|
||||
image = model.image.get_image_by_id(namespace, repository, image_id)
|
||||
try:
|
||||
image = model.image.get_image_by_id(namespace, repository, image_id)
|
||||
except model.InvalidImageException:
|
||||
abort(404, 'Image %(image_id)s not found', issue='unknown-image', image_id=image_id)
|
||||
|
||||
parents = model.image.get_parent_images(namespace, repository, image)
|
||||
|
||||
ancestry_docker_ids = [image.docker_image_id]
|
||||
|
|
|
@ -68,9 +68,15 @@ class TestGarbageCollection(unittest.TestCase):
|
|||
if not image_id in image_map:
|
||||
image_map[image_id] = self.createImage(image_id, repo, namespace)
|
||||
|
||||
v1_metadata = {
|
||||
'id': image_id,
|
||||
}
|
||||
if parent is not None:
|
||||
v1_metadata['parent'] = parent.docker_image_id
|
||||
|
||||
# Set the ancestors for the image.
|
||||
parent = model.image.set_image_metadata(image_id, namespace, name, '', '', '',
|
||||
parent=parent)
|
||||
v1_metadata, parent=parent)
|
||||
|
||||
# Set the tag for the image.
|
||||
model.tag.create_or_update_tag(namespace, name, tag_name, image_ids[-1])
|
||||
|
|
Reference in a new issue