Fix for hooks executing when using --dry-run (#160).

This commit is contained in:
Dan Helfman
2019-05-07 16:06:31 -07:00
parent 1c88dda76a
commit a291477c19
5 changed files with 36 additions and 12 deletions
@@ -7,7 +7,7 @@ def test_execute_hook_invokes_each_command():
subprocess = flexmock(module.subprocess)
subprocess.should_receive('check_call').with_args(':', shell=True).once()
module.execute_hook([':'], 'config.yaml', 'pre-backup')
module.execute_hook([':'], 'config.yaml', 'pre-backup', dry_run=False)
def test_execute_hook_with_multiple_commands_invokes_each_command():
@@ -15,8 +15,15 @@ def test_execute_hook_with_multiple_commands_invokes_each_command():
subprocess.should_receive('check_call').with_args(':', shell=True).once()
subprocess.should_receive('check_call').with_args('true', shell=True).once()
module.execute_hook([':', 'true'], 'config.yaml', 'pre-backup')
module.execute_hook([':', 'true'], 'config.yaml', 'pre-backup', dry_run=False)
def test_execute_hook_with_dry_run_skips_commands():
subprocess = flexmock(module.subprocess)
subprocess.should_receive('check_call').never()
module.execute_hook([':', 'true'], 'config.yaml', 'pre-backup', dry_run=True)
def test_execute_hook_with_empty_commands_does_not_raise():
module.execute_hook([], 'config.yaml', 'post-backup')
module.execute_hook([], 'config.yaml', 'post-backup', dry_run=False)