From e8ed43b46fed8a08d620e55e517cf9ab3a744539 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 31 Oct 2018 11:38:55 -0400 Subject: [PATCH] Fix name of reversion field in new Tag table and add a test --- data/database.py | 2 +- ...b_add_tag_tagkind_and_manifestchild_tables.py | 2 +- data/model/test/test_tag.py | 16 ++++++++++++++++ data/registry_model/test/test_interface.py | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/data/database.py b/data/database.py index 3601fd1a3..6ea7dd473 100644 --- a/data/database.py +++ b/data/database.py @@ -1400,7 +1400,7 @@ class Tag(BaseModel): lifetime_start_ms = BigIntegerField(default=get_epoch_timestamp_ms) lifetime_end_ms = BigIntegerField(null=True, index=True) hidden = BooleanField(default=False) - reverted = BooleanField(default=False) + reversion = BooleanField(default=False) tag_kind = EnumField(TagKind) linked_tag = ForeignKeyField('self', null=True, backref='tag_parents') diff --git a/data/migrations/versions/10f45ee2310b_add_tag_tagkind_and_manifestchild_tables.py b/data/migrations/versions/10f45ee2310b_add_tag_tagkind_and_manifestchild_tables.py index a29fd5fdc..0d67bee82 100644 --- a/data/migrations/versions/10f45ee2310b_add_tag_tagkind_and_manifestchild_tables.py +++ b/data/migrations/versions/10f45ee2310b_add_tag_tagkind_and_manifestchild_tables.py @@ -47,7 +47,7 @@ def upgrade(tables, tester): sa.Column('lifetime_start_ms', sa.BigInteger(), nullable=False), sa.Column('lifetime_end_ms', sa.BigInteger(), nullable=True), sa.Column('hidden', sa.Boolean(), nullable=False, server_default=sa.sql.expression.false()), - sa.Column('reverted', sa.Boolean(), nullable=False, server_default=sa.sql.expression.false()), + sa.Column('reversion', sa.Boolean(), nullable=False, server_default=sa.sql.expression.false()), sa.Column('tag_kind_id', sa.Integer(), nullable=False), sa.Column('linked_tag_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['linked_tag_id'], ['tag.id'], name=op.f('fk_tag_linked_tag_id_tag')), diff --git a/data/model/test/test_tag.py b/data/model/test/test_tag.py index baa164d5b..d04ffb96c 100644 --- a/data/model/test/test_tag.py +++ b/data/model/test/test_tag.py @@ -146,6 +146,7 @@ def assert_tags(repository, *args): oci_tag = _get_oci_tag(tag) assert oci_tag.name == tag.name assert not oci_tag.hidden + assert oci_tag.reversion == tag.reversion if tag.lifetime_end_ts: assert oci_tag.lifetime_end_ms == (tag.lifetime_end_ts * 1000) @@ -156,6 +157,21 @@ def assert_tags(repository, *args): assert expected in tags_dict +def test_create_reversion_tag(initialized_db): + repository = create_repository('devtable', 'somenewrepo', None) + manifest = Manifest.get() + image1 = find_create_or_link_image('foobarimage1', repository, None, {}, 'local_us') + + footag = create_or_update_tag_for_repo(repository, 'foo', image1.docker_image_id, + oci_manifest=manifest, reversion=True) + assert footag.reversion + + oci_tag = _get_oci_tag(footag) + assert oci_tag.name == footag.name + assert not oci_tag.hidden + assert oci_tag.reversion == footag.reversion + + def test_list_active_tags(initialized_db): # Create a new repository. repository = create_repository('devtable', 'somenewrepo', None) diff --git a/data/registry_model/test/test_interface.py b/data/registry_model/test/test_interface.py index 1e5a8d510..aa9f35d81 100644 --- a/data/registry_model/test/test_interface.py +++ b/data/registry_model/test/test_interface.py @@ -571,7 +571,7 @@ def test_torrent_info(registry_model): registry_model.set_torrent_info(layers[0].blob, 2, 'foo') # Check the information we've set. - torrent_info = pre_oci_model.get_torrent_info(layers[0].blob) + torrent_info = registry_model.get_torrent_info(layers[0].blob) assert torrent_info is not None assert torrent_info.piece_length == 2 assert torrent_info.pieces == 'foo'