Skip to content

Commit

Permalink
Add test for formatting of version string
Browse files Browse the repository at this point in the history
  • Loading branch information
Amund211 committed Sep 6, 2022
1 parent dfecd05 commit 4eb541a
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/examples/overlay/test_version_string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from examples.overlay import VERSION_STRING


def test_version_string() -> None:
"""
Assert proper formatting of the version string: v<major>.<minor>.<patch>(-dev)
We use the version string in the filename of the compiled binary in gh actions.
Make sure that works by not including any special characters
"""

# No special characters
assert set(VERSION_STRING).issubset("v0123456789.-dev")

# Version starts with v
assert VERSION_STRING[0] == "v"

main_version, *rest = VERSION_STRING[1:].split("-")

# Only allowed suffix is -dev
assert rest == [] or rest == ["dev"]

major, minor, patch = main_version.split(".")

# Properly formatted numbers
for number in (major, minor, patch):
assert str(int(number)) == number

0 comments on commit 4eb541a

Please sign in to comment.