Added new flags to prune test for review

Signed-off-by: Chirag Aggarwal <thechiragaggarwal@gmail.com>
This commit is contained in:
Chirag Aggarwal 2023-04-24 20:43:34 +05:30
parent 96aca4f446
commit 8aaba9bb0a
1 changed files with 24 additions and 17 deletions

View File

@ -166,23 +166,6 @@ def test_prune_archives_with_log_debug_calls_borg_with_debug_parameter():
)
# def test_prune_archives_with_dry_run_calls_borg_with_dry_run_parameter():
# flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
# flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
# flexmock(module).should_receive('make_prune_flags').and_return(BASE_PRUNE_FLAGS)
# flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
# insert_execute_command_mock(PRUNE_COMMAND + ('--dry-run', 'repo'), logging.INFO)
# prune_arguments = flexmock(stats=False, list_archives=False)
# module.prune_archives(
# repository_path='repo',
# storage_config={},
# dry_run=True,
# retention_config=flexmock(),
# local_borg_version='1.2.3',
# prune_arguments=prune_arguments,
# )
def test_prune_archives_with_dry_run_calls_borg_with_dry_run_parameter():
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
@ -329,3 +312,27 @@ def test_prune_archives_with_extra_borg_options_calls_borg_with_extra_options():
local_borg_version='1.2.3',
prune_arguments=prune_arguments,
)
def test_prune_archives_with_date_based_matching_calls_borg_with_date_based_flags():
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
flexmock(module).should_receive('make_prune_flags').and_return(BASE_PRUNE_FLAGS)
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
insert_execute_command_mock(
PRUNE_COMMAND
+ ('--newer', '1d', '--newest', '1y', '--older', '1m', '--oldest', '1w', 'repo'),
logging.INFO,
)
prune_arguments = flexmock(
stats=False, list_archives=False, newer='1d', newest='1y', older='1m', oldest='1w'
)
module.prune_archives(
dry_run=False,
repository_path='repo',
storage_config={},
retention_config=flexmock(),
local_borg_version='1.2.3',
prune_arguments=prune_arguments,
)