2018-07-11 12:50:42 +00:00
|
|
|
"""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(
|
2020-11-17 20:38:31 +00:00
|
|
|
runner, yadm_cmd, paths, exists, executable, code, expect):
|
2018-07-11 12:50:42 +00:00
|
|
|
"""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)
|
2020-11-17 20:38:31 +00:00
|
|
|
run = runner(command=yadm_cmd('bootstrap'))
|
2018-07-11 12:50:42 +00:00
|
|
|
assert run.code == code
|
2021-01-05 20:57:32 +00:00
|
|
|
if exists and executable:
|
|
|
|
assert run.err == ''
|
|
|
|
assert expect in run.out
|
|
|
|
else:
|
|
|
|
assert expect in run.err
|
|
|
|
assert run.out == ''
|