2018-07-11 12:50:42 +00:00
|
|
|
"""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')
|
|
|
|
|
|
|
|
|
2020-12-21 22:53:44 +00:00
|
|
|
@pytest.mark.parametrize('cmd', ['--version', 'version'])
|
2018-07-11 12:50:42 +00:00
|
|
|
def test_reported_version(
|
2020-12-21 22:53:44 +00:00
|
|
|
runner, yadm_cmd, cmd, expected_version):
|
2022-01-17 17:45:09 +00:00
|
|
|
"""Report correct version and bash/git versions"""
|
2020-12-21 22:53:44 +00:00
|
|
|
run = runner(command=yadm_cmd(cmd))
|
2018-07-11 12:50:42 +00:00
|
|
|
assert run.success
|
|
|
|
assert run.err == ''
|
2022-01-17 17:45:09 +00:00
|
|
|
assert 'bash version' in run.out
|
|
|
|
assert 'git version' in run.out
|
|
|
|
assert run.out.endswith(f'\nyadm version {expected_version}\n')
|