test_bootstrap.py 838 B

12345678910111213141516171819202122232425262728293031
  1. """Test bootstrap"""
  2. import pytest
  3. @pytest.mark.parametrize(
  4. 'exists, executable, code, expect', [
  5. (False, False, 1, 'Cannot execute bootstrap'),
  6. (True, False, 1, 'is not an executable program'),
  7. (True, True, 123, 'Bootstrap successful'),
  8. ], ids=[
  9. 'missing',
  10. 'not executable',
  11. 'executable',
  12. ])
  13. def test_bootstrap(
  14. runner, yadm_y, paths, exists, executable, code, expect):
  15. """Test bootstrap command"""
  16. if exists:
  17. paths.bootstrap.write('')
  18. if executable:
  19. paths.bootstrap.write(
  20. '#!/bin/bash\n'
  21. f'echo {expect}\n'
  22. f'exit {code}\n'
  23. )
  24. paths.bootstrap.chmod(0o775)
  25. run = runner(command=yadm_y('bootstrap'))
  26. assert run.code == code
  27. assert run.err == ''
  28. assert expect in run.out