From 4663bf4194b105704310cfb8bc12fcdbc4aa5b16 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 19 Jun 2017 17:24:02 -0400 Subject: [PATCH] Add additional test for tag expiration --- data/model/test/test_tag.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/data/model/test/test_tag.py b/data/model/test/test_tag.py index 8fa0eb852..1e7177310 100644 --- a/data/model/test/test_tag.py +++ b/data/model/test/test_tag.py @@ -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')