Skip to content

Commit

Permalink
Merge pull request #39 from redhatcloudx/fix-google-version-regex
Browse files Browse the repository at this point in the history
Fix arm64 error at google/versions
  • Loading branch information
major authored Jun 28, 2024
2 parents 520da55 + 7d5b493 commit be828f8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
6 changes: 5 additions & 1 deletion cid/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,11 @@ def find_available_google_versions(db: Session) -> list:
"""
versions = [x.version for x in db.query(GoogleImage.version).distinct()]

return sorted(versions, key=Version, reverse=True)
def version_key(version: str) -> Version:
parts = [part for part in version.split(".") if part.isdigit()]
return Version(".".join(parts))

return sorted(versions, key=version_key, reverse=True)


def find_images_for_version(db: Session, version: str) -> list:
Expand Down
23 changes: 20 additions & 3 deletions tests/test_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,14 +434,31 @@ def test_find_available_google_versions(db):
GoogleImage(id="id-a", version="8.2.0"),
GoogleImage(id="id-b", version="7.9.0"),
GoogleImage(id="id-c", version="9.5.0"),
GoogleImage(id="id-d", version="10.0.0"),
GoogleImage(id="id-e", version="9.5.0"),
GoogleImage(id="id-d", version="9.7.3"),
GoogleImage(id="id-e", version="10.0.0"),
GoogleImage(id="id-g", version="9.5.0"),
GoogleImage(id="id-h", version="9.7.arm64"),
GoogleImage(id="id-i", version="9.7.arm64"),
GoogleImage(id="id-j", version="9.arm64"),
GoogleImage(id="id-k", version="9.arm64"),
GoogleImage(id="id-l", version="9.7.1.arm64"),
GoogleImage(id="id-m", version="9.7.1.arm64"),
]
db.add_all(images)
db.commit()

result = crud.find_available_google_versions(db)
assert result == ["10.0.0", "9.5.0", "8.2.0", "7.9.0"]

assert result == [
"10.0.0",
"9.7.3",
"9.7.1.arm64",
"9.7.arm64",
"9.5.0",
"9.arm64",
"8.2.0",
"7.9.0",
]


def test_find_images_for_version(db):
Expand Down

0 comments on commit be828f8

Please sign in to comment.