Fix NPE in changing the expiration of a tag

This commit is contained in:
Joseph Schorr 2018-11-02 14:54:13 -04:00
parent 417b3f9fc2
commit 4779e05f55
2 changed files with 8 additions and 1 deletions

View file

@ -895,7 +895,7 @@ def set_tag_end_ts(tag, end_ts):
""" Sets the end timestamp for a tag. Should only be called by change_tag_expiration """ Sets the end timestamp for a tag. Should only be called by change_tag_expiration
or tests. or tests.
""" """
end_ms = end_ts * 1000 end_ms = end_ts * 1000 if end_ts is not None else None
with db_transaction(): with db_transaction():
# Note: We check not just the ID of the tag but also its lifetime_end_ts, to ensure that it has # Note: We check not just the ID of the tag but also its lifetime_end_ts, to ensure that it has

View file

@ -209,6 +209,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')
# Set the expirations to be explicitly empty.
set_tag_end_ts(footag, None)
set_tag_end_ts(bartag, None)
# 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. # Mark as a tag as expiring in the far future, and make sure it is still returned.
set_tag_end_ts(footag, footag.lifetime_start_ts + 10000000) set_tag_end_ts(footag, footag.lifetime_start_ts + 10000000)