1
0
Fork 0
mirror of synced 2024-05-28 21:11:11 -04:00
yadm/test/test_bootstrap.py
Erik Flodin 6378fe3073
Print errors to stderr
This makes it possible to run e.g. "yadm -Y foo introspect repo
2>/dev/null" and get an empty output instead of getting the error
message about foo not being fully qualified.
2021-01-05 21:57:32 +01:00

36 lines
952 B
Python

"""Test bootstrap"""
import pytest
@pytest.mark.parametrize(
'exists, executable, code, expect', [
(False, False, 1, 'Cannot execute bootstrap'),
(True, False, 1, 'is not an executable program'),
(True, True, 123, 'Bootstrap successful'),
], ids=[
'missing',
'not executable',
'executable',
])
def test_bootstrap(
runner, yadm_cmd, paths, exists, executable, code, expect):
"""Test bootstrap command"""
if exists:
paths.bootstrap.write('')
if executable:
paths.bootstrap.write(
'#!/bin/bash\n'
f'echo {expect}\n'
f'exit {code}\n'
)
paths.bootstrap.chmod(0o775)
run = runner(command=yadm_cmd('bootstrap'))
assert run.code == code
if exists and executable:
assert run.err == ''
assert expect in run.out
else:
assert expect in run.err
assert run.out == ''