1
0
Fork 0
mirror of synced 2024-11-05 01:08:59 -05:00
yadm/test/test_bootstrap.py

34 lines
907 B
Python
Raw Normal View History

"""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):
"""Test bootstrap command"""
if exists:
2023-07-10 15:43:17 -04:00
paths.bootstrap.write("")
if executable:
2023-07-10 15:43:17 -04:00
paths.bootstrap.write("#!/bin/bash\n" f"echo {expect}\n" f"exit {code}\n")
paths.bootstrap.chmod(0o775)
2023-07-10 15:43:17 -04:00
run = runner(command=yadm_cmd("bootstrap"))
assert run.code == code
if exists and executable:
2023-07-10 15:43:17 -04:00
assert run.err == ""
assert expect in run.out
else:
assert expect in run.err
2023-07-10 15:43:17 -04:00
assert run.out == ""