1
0
Fork 0
mirror of synced 2024-11-05 01:08:59 -05:00
yadm/test/test_version.py
Tim Byrne 62b109ad2d
Rename yadm_y -> yadm_cmd
-Y is no longer used when running commands
2020-11-22 17:09:44 -06:00

35 lines
938 B
Python

"""Test version"""
import re
import pytest
@pytest.fixture(scope='module')
def expected_version(yadm):
"""
Expected semantic version number. This is taken directly out of yadm,
searching for the VERSION= string.
"""
yadm_version = re.findall(
r'VERSION=([^\n]+)',
open(yadm).read())
if yadm_version:
return yadm_version[0]
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
assert re.search(r'^\d+\.\d+\.\d+$', expected_version), (
'does not conform to MAJOR.MINOR.PATCH')
def test_reported_version(
runner, yadm_cmd, expected_version):
"""Report correct version"""
run = runner(command=yadm_cmd('version'))
assert run.success
assert run.err == ''
assert run.out == f'yadm {expected_version}\n'