Add additional test for tag expiration

This commit is contained in:
Joseph Schorr 2017-06-19 17:24:02 -04:00
parent 78652de3ee
commit 4663bf4194

View file

@ -1,6 +1,7 @@
import pytest
from mock import patch
from time import time
from data.database import Image, RepositoryTag, ImageStorage, Repository
from data.model.repository import create_repository
@ -112,7 +113,7 @@ def assert_tags(repository, *args):
for tag in tags:
assert not tag.name in tags_dict
assert not tag.hidden
assert not tag.lifetime_end_ts
assert not tag.lifetime_end_ts or tag.lifetime_end_ts > time()
tags_dict[tag.name] = tag
@ -145,6 +146,13 @@ def test_list_active_tags(initialized_db):
# Make sure they are returned.
assert_tags(repository, 'foo', 'bar')
# Mark as a tag as expiring in the far future, and make sure it is still returned.
footag.lifetime_end_ts = footag.lifetime_start_ts + 10000000
footag.save()
# Make sure they are returned.
assert_tags(repository, 'foo', 'bar')
# Delete a tag and make sure it isn't returned.
footag = delete_tag('devtable', 'somenewrepo', 'foo')
footag.lifetime_end_ts -= 4
@ -159,6 +167,13 @@ def test_list_active_tags(initialized_db):
assert_tags(repository, 'foo', 'bar')
# Mark as a tag as expiring in the far future, and make sure it is still returned.
footag.lifetime_end_ts = footag.lifetime_start_ts + 10000000
footag.save()
# Make sure they are returned.
assert_tags(repository, 'foo', 'bar')
# "Move" foo by updating it and make sure we don't get duplicates.
create_or_update_tag('devtable', 'somenewrepo', 'foo', image2.docker_image_id)
assert_tags(repository, 'foo', 'bar')