-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for formatting of version string
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |