nix-update/tests/test_gitea.py
figsoda 2fdb989360 improve version assertions in tests
fixes broken tests due to flaky string comparisons
2023-04-26 23:27:59 -04:00

37 lines
1008 B
Python

import subprocess
import conftest
from nix_update import main
def test_main(helpers: conftest.Helpers) -> None:
with helpers.testpkgs(init_git=True) as path:
main(["--file", str(path), "--commit", "gitea"])
version = subprocess.run(
[
"nix",
"eval",
"--raw",
"--extra-experimental-features",
"nix-command",
"-f",
path,
"gitea.version",
],
check=True,
text=True,
stdout=subprocess.PIPE,
).stdout.strip()
assert int(version) >= 30
commit = subprocess.run(
["git", "-C", path, "log", "-1"],
text=True,
stdout=subprocess.PIPE,
check=True,
).stdout.strip()
print(commit)
assert version in commit
assert "gitea" in commit
assert "https://codeberg.org/nsxiv/nsxiv/compare/v29...v" in commit