test_unit_bootstrap_available.py 975 B

123456789101112131415161718192021222324252627282930313233
  1. """Unit tests: bootstrap_available"""
  2. def test_bootstrap_missing(runner, paths):
  3. """Test result of bootstrap_available, when bootstrap missing"""
  4. run_test(runner, paths, False)
  5. def test_bootstrap_no_exec(runner, paths):
  6. """Test result of bootstrap_available, when bootstrap not executable"""
  7. paths.bootstrap.write('')
  8. paths.bootstrap.chmod(0o644)
  9. run_test(runner, paths, False)
  10. def test_bootstrap_exec(runner, paths):
  11. """Test result of bootstrap_available, when bootstrap executable"""
  12. paths.bootstrap.write('')
  13. paths.bootstrap.chmod(0o775)
  14. run_test(runner, paths, True)
  15. def run_test(runner, paths, success):
  16. """Run bootstrap_available, and test result"""
  17. script = f"""
  18. YADM_TEST=1 source {paths.pgm}
  19. YADM_BOOTSTRAP='{paths.bootstrap}'
  20. bootstrap_available
  21. """
  22. run = runner(command=['bash'], inp=script)
  23. assert run.success == success
  24. assert run.err == ''
  25. assert run.out == ''