From ac566c70541dddb4f09c7c0780055b9195b06d6c Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 11 Mar 2019 12:23:51 -0400 Subject: [PATCH] Fix NPE when setting tag to not expire --- data/model/oci/tag.py | 2 +- data/model/oci/test/test_oci_tag.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/data/model/oci/tag.py b/data/model/oci/tag.py index 0a7706c96..bba4f766c 100644 --- a/data/model/oci/tag.py +++ b/data/model/oci/tag.py @@ -421,7 +421,7 @@ def set_tag_end_ms(tag, end_ms): .where(TagToRepositoryTag.tag == tag) .get()).repository_tag - old_style_tag.lifetime_end_ts = end_ms / 1000 + old_style_tag.lifetime_end_ts = end_ms / 1000 if end_ms is not None else None old_style_tag.save() except TagToRepositoryTag.DoesNotExist: pass diff --git a/data/model/oci/test/test_oci_tag.py b/data/model/oci/test/test_oci_tag.py index 5e1b6a2bb..c27c182df 100644 --- a/data/model/oci/test/test_oci_tag.py +++ b/data/model/oci/test/test_oci_tag.py @@ -214,6 +214,13 @@ def test_change_tag_expiration(timedelta, expected_timedelta, initialized_db): expected_ms = (updated_tag.lifetime_start_ms + offset) assert updated_tag.lifetime_end_ms == expected_ms + original_end_ms, okay = change_tag_expiration(tag, None) + assert okay + assert original_end_ms == expected_ms + + updated_tag = Tag.get(id=tag.id) + assert updated_tag.lifetime_end_ms is None + def test_set_tag_expiration_for_manifest(initialized_db): tag = Tag.get()