|
@@ -68,26 +68,34 @@ 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)
|
|
|
|
- flexmock(module).should_receive('execute_command').once()
|
|
|
|
|
|
+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(
|
|
module.compact_segments(
|
|
repository_path='repo',
|
|
repository_path='repo',
|
|
config={},
|
|
config={},
|
|
- local_borg_version='1.4.1',
|
|
|
|
|
|
+ local_borg_version='1.2.3',
|
|
global_arguments=flexmock(),
|
|
global_arguments=flexmock(),
|
|
dry_run=True,
|
|
dry_run=True,
|
|
)
|
|
)
|
|
|
|
|
|
- # Test borg version that does not support dry run.
|
|
|
|
- logger_mock.should_receive('info').with_args('Skipping compact (dry run)').once()
|
|
|
|
|
|
+
|
|
|
|
+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(
|
|
module.compact_segments(
|
|
repository_path='repo',
|
|
repository_path='repo',
|
|
config={},
|
|
config={},
|
|
- local_borg_version='1.2.3',
|
|
|
|
|
|
+ local_borg_version='1.4.1',
|
|
global_arguments=flexmock(),
|
|
global_arguments=flexmock(),
|
|
dry_run=True,
|
|
dry_run=True,
|
|
)
|
|
)
|