2019-04-03 07:30:14 +02:00
|
|
|
from flexmock import flexmock
|
2019-05-13 23:39:10 +02:00
|
|
|
|
2019-04-03 07:30:14 +02:00
|
|
|
from borgmatic.borg import execute as module
|
|
|
|
|
|
|
|
|
|
|
|
def test_execute_command_calls_full_command():
|
|
|
|
full_command = ['foo', 'bar']
|
2019-06-12 01:42:04 +02:00
|
|
|
flexmock(module).should_receive('execute_and_log_output').with_args(full_command).once()
|
2019-04-03 07:30:14 +02:00
|
|
|
|
|
|
|
output = module.execute_command(full_command)
|
|
|
|
|
|
|
|
assert output is None
|
|
|
|
|
|
|
|
|
|
|
|
def test_execute_command_captures_output():
|
|
|
|
full_command = ['foo', 'bar']
|
|
|
|
expected_output = '[]'
|
2019-06-12 01:42:04 +02:00
|
|
|
flexmock(module.subprocess).should_receive('check_output').with_args(full_command).and_return(
|
2019-04-03 07:30:14 +02:00
|
|
|
flexmock(decode=lambda: expected_output)
|
|
|
|
).once()
|
|
|
|
|
|
|
|
output = module.execute_command(full_command, capture_output=True)
|
|
|
|
|
|
|
|
assert output == expected_output
|