Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
fixes: pulp#1391

Signed-off-by: James Tanner <tanner.jc@gmail.com>
  • Loading branch information
jctanner committed Mar 17, 2023
1 parent f895ea7 commit f08893a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pulp_ansible/app/tasks/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@ def is_new_highest(new, old):
return True
if new.prerelease and not old.prerelease:
return False
if not new.prerelease and old.prerelease:
return True
return new > old

# did we have one set previously for this collection?
Expand Down
26 changes: 26 additions & 0 deletions pulp_ansible/tests/unit/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,32 @@ def test_is_highest_set(self):
is True
)

def test_is_highest_set_on_multple_stable_releases(self):
namespace = randstr()
name = randstr()
specs = [
(namespace, name, "1.0.1"),
(namespace, name, "2.0.1"),
]

collection_versions = build_cvs_from_specs(specs)
for cv in collection_versions:
_update_highest_version(cv, save=True)

assert (
CollectionVersion.objects.filter(namespace=namespace, name=name, version="1.0.1")
.first()
.is_highest
is False
)

assert (
CollectionVersion.objects.filter(namespace=namespace, name=name, version="2.0.1")
.first()
.is_highest
is True
)

def test_is_highest_set_on_single_prerelease(self):
namespace = randstr()
name = randstr()
Expand Down

0 comments on commit f08893a

Please sign in to comment.