mirror of
https://github.com/borgmatic-collective/borgmatic.git
synced 2026-07-31 05:33:01 +02:00
review changes
This commit is contained in:
@@ -68,9 +68,28 @@ def test_compact_segments_with_log_debug_calls_borg_with_debug_flag():
|
||||
)
|
||||
|
||||
|
||||
def test_compact_segments_with_dry_run_skips_borg_call():
|
||||
# Test borg version supports dry run.
|
||||
logger_mock = flexmock(logging)
|
||||
def test_compact_segments_with_dry_run_skips_borg_call_when_feature_unavailable():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.feature).should_receive('available').with_args(
|
||||
module.feature.Feature.DRY_RUN_COMPACT, '1.2.3'
|
||||
).and_return(False)
|
||||
flexmock(module).should_receive('execute_command').never()
|
||||
flexmock(logging).should_receive('info').with_args('Skipping compact (dry run)').once()
|
||||
|
||||
module.compact_segments(
|
||||
repository_path='repo',
|
||||
config={},
|
||||
local_borg_version='1.2.3',
|
||||
global_arguments=flexmock(),
|
||||
dry_run=True,
|
||||
)
|
||||
|
||||
|
||||
def test_compact_segments_with_dry_run_executes_borg_call_when_feature_available():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.feature).should_receive('available').with_args(
|
||||
module.feature.Feature.DRY_RUN_COMPACT, '1.4.1'
|
||||
).and_return(True)
|
||||
flexmock(module).should_receive('execute_command').once()
|
||||
|
||||
module.compact_segments(
|
||||
@@ -81,17 +100,6 @@ def test_compact_segments_with_dry_run_skips_borg_call():
|
||||
dry_run=True,
|
||||
)
|
||||
|
||||
# Test borg version that does not support dry run.
|
||||
logger_mock.should_receive('info').with_args('Skipping compact (dry run)').once()
|
||||
|
||||
module.compact_segments(
|
||||
repository_path='repo',
|
||||
config={},
|
||||
local_borg_version='1.2.3',
|
||||
global_arguments=flexmock(),
|
||||
dry_run=True,
|
||||
)
|
||||
|
||||
|
||||
def test_compact_segments_with_local_path_calls_borg_via_local_path():
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
|
||||
@@ -177,6 +177,10 @@ def test_make_environment_with_integer_variable_value():
|
||||
|
||||
def test_make_environment_with_use_chunks_archive_should_set_correct_environment_value():
|
||||
flexmock(module.os).should_receive('environ').and_return({'USER': 'root'})
|
||||
flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
||||
'resolve_credential'
|
||||
).and_return(None)
|
||||
flexmock(module.os).should_receive('pipe').never()
|
||||
|
||||
environment = module.make_environment({'use_chunks_archive': True})
|
||||
assert environment.get('BORG_USE_CHUNKS_ARCHIVE') == 'yes'
|
||||
|
||||
Reference in New Issue
Block a user