2018-07-11 08:50:42 -04:00
|
|
|
"""Test bootstrap"""
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
2023-07-10 15:43:17 -04:00
|
|
|
"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):
|
2018-07-11 08:50:42 -04:00
|
|
|
"""Test bootstrap command"""
|
|
|
|
if exists:
|
2023-07-10 15:43:17 -04:00
|
|
|
paths.bootstrap.write("")
|
2018-07-11 08:50:42 -04:00
|
|
|
if executable:
|
2023-07-10 15:43:17 -04:00
|
|
|
paths.bootstrap.write("#!/bin/bash\n" f"echo {expect}\n" f"exit {code}\n")
|
2018-07-11 08:50:42 -04:00
|
|
|
paths.bootstrap.chmod(0o775)
|
2023-07-10 15:43:17 -04:00
|
|
|
run = runner(command=yadm_cmd("bootstrap"))
|
2018-07-11 08:50:42 -04:00
|
|
|
assert run.code == code
|
2021-01-05 15:57:32 -05:00
|
|
|
if exists and executable:
|
2023-07-10 15:43:17 -04:00
|
|
|
assert run.err == ""
|
2021-01-05 15:57:32 -05:00
|
|
|
assert expect in run.out
|
|
|
|
else:
|
|
|
|
assert expect in run.err
|
2023-07-10 15:43:17 -04:00
|
|
|
assert run.out == ""
|