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

39 lines
1.1 KiB
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", "gitlab"])
version = subprocess.run(
[
"nix",
"eval",
"--raw",
"--extra-experimental-features",
"nix-command",
"-f",
path,
"gitlab.version",
],
check=True,
text=True,
stdout=subprocess.PIPE,
).stdout.strip()
assert tuple(map(int, version.split("."))) >= (0, 22, 0)
commit = subprocess.run(
["git", "-C", path, "log", "-1"],
text=True,
stdout=subprocess.PIPE,
check=True,
).stdout.strip()
print(commit)
assert version in commit
assert "gitlab" in commit
assert (
"https://gitlab.gnome.org/world/phosh/phosh/-/compare/v0.20.0...v" in commit
)