1
0
Fork 0
mirror of synced 2024-06-24 07:51:09 -04:00
yadm/test/test_version.py

37 lines
1.1 KiB
Python
Raw Normal View History

"""Test version"""
import re
2023-07-10 10:14:33 -04:00
import pytest
2023-07-10 15:43:17 -04:00
@pytest.fixture(scope="module")
def expected_version(yadm):
"""
Expected semantic version number. This is taken directly out of yadm,
searching for the VERSION= string.
"""
2023-07-10 15:43:17 -04:00
with open(yadm, encoding="utf-8") as source_file:
yadm_version = re.findall(r"VERSION=([^\n]+)", source_file.read())
if yadm_version:
return yadm_version[0]
2023-07-10 15:43:17 -04:00
pytest.fail(f"version not found in {yadm}")
return "not found"
def test_semantic_version(expected_version):
"""Version is semantic"""
# semantic version conforms to MAJOR.MINOR.PATCH
2023-07-10 15:43:17 -04:00
assert re.search(r"^\d+\.\d+\.\d+$", expected_version), "does not conform to MAJOR.MINOR.PATCH"
2023-07-10 15:43:17 -04:00
@pytest.mark.parametrize("cmd", ["--version", "version"])
def test_reported_version(runner, yadm_cmd, cmd, expected_version):
2022-01-17 12:45:09 -05:00
"""Report correct version and bash/git versions"""
run = runner(command=yadm_cmd(cmd))
assert run.success
2023-07-10 15:43:17 -04:00
assert run.err == ""
assert "bash version" in run.out
assert "git version" in run.out
assert run.out.endswith(f"\nyadm version {expected_version}\n")