Add additional test for tag expiration
This commit is contained in:
parent
78652de3ee
commit
4663bf4194
1 changed files with 16 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from mock import patch
|
from mock import patch
|
||||||
|
from time import time
|
||||||
|
|
||||||
from data.database import Image, RepositoryTag, ImageStorage, Repository
|
from data.database import Image, RepositoryTag, ImageStorage, Repository
|
||||||
from data.model.repository import create_repository
|
from data.model.repository import create_repository
|
||||||
|
@ -112,7 +113,7 @@ def assert_tags(repository, *args):
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
assert not tag.name in tags_dict
|
assert not tag.name in tags_dict
|
||||||
assert not tag.hidden
|
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
|
tags_dict[tag.name] = tag
|
||||||
|
|
||||||
|
@ -145,6 +146,13 @@ def test_list_active_tags(initialized_db):
|
||||||
# Make sure they are returned.
|
# Make sure they are returned.
|
||||||
assert_tags(repository, 'foo', 'bar')
|
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.
|
# Delete a tag and make sure it isn't returned.
|
||||||
footag = delete_tag('devtable', 'somenewrepo', 'foo')
|
footag = delete_tag('devtable', 'somenewrepo', 'foo')
|
||||||
footag.lifetime_end_ts -= 4
|
footag.lifetime_end_ts -= 4
|
||||||
|
@ -159,6 +167,13 @@ def test_list_active_tags(initialized_db):
|
||||||
|
|
||||||
assert_tags(repository, 'foo', 'bar')
|
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.
|
# "Move" foo by updating it and make sure we don't get duplicates.
|
||||||
create_or_update_tag('devtable', 'somenewrepo', 'foo', image2.docker_image_id)
|
create_or_update_tag('devtable', 'somenewrepo', 'foo', image2.docker_image_id)
|
||||||
assert_tags(repository, 'foo', 'bar')
|
assert_tags(repository, 'foo', 'bar')
|
||||||
|
|
Reference in a new issue