|
@@ -25,9 +25,15 @@ def test_recreate_archive_dry_run_skips_execution():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
flexmock(module.borgmatic.execute).should_receive('execute_command').never()
|
|
|
|
|
|
recreate_arguments = flexmock(
|
|
@@ -57,10 +63,16 @@ def test_recreate_calls_borg_with_required_flags():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
- insert_execute_command_mock(('borg', 'recreate', 'repo::archive'))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
+ insert_execute_command_mock(('borg', 'recreate', '--repo', 'repo'))
|
|
|
|
|
|
module.recreate_archive(
|
|
|
repository='repo',
|
|
@@ -86,10 +98,16 @@ def test_recreate_with_remote_path():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
- insert_execute_command_mock(('borg', 'recreate', '--remote-path', 'borg1', 'repo::archive'))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
+ insert_execute_command_mock(('borg', 'recreate', '--remote-path', 'borg1', '--repo', 'repo'))
|
|
|
|
|
|
module.recreate_archive(
|
|
|
repository='repo',
|
|
@@ -115,10 +133,16 @@ def test_recreate_with_lock_wait():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
- insert_execute_command_mock(('borg', 'recreate', '--lock-wait', '5', 'repo::archive'))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
+ insert_execute_command_mock(('borg', 'recreate', '--lock-wait', '5', '--repo', 'repo'))
|
|
|
|
|
|
module.recreate_archive(
|
|
|
repository='repo',
|
|
@@ -143,10 +167,16 @@ def test_recreate_with_log_info():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
- insert_execute_command_mock(('borg', 'recreate', '--info', 'repo::archive'))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
+ insert_execute_command_mock(('borg', 'recreate', '--info', '--repo', 'repo'))
|
|
|
|
|
|
insert_logging_mock(logging.INFO)
|
|
|
|
|
@@ -173,10 +203,16 @@ def test_recreate_with_log_debug():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
- insert_execute_command_mock(('borg', 'recreate', '--debug', '--show-rc', 'repo::archive'))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
+ insert_execute_command_mock(('borg', 'recreate', '--debug', '--show-rc', '--repo', 'repo'))
|
|
|
insert_logging_mock(logging.DEBUG)
|
|
|
|
|
|
module.recreate_archive(
|
|
@@ -202,10 +238,16 @@ def test_recreate_with_log_json():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
- insert_execute_command_mock(('borg', 'recreate', '--log-json', 'repo::archive'))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
+ insert_execute_command_mock(('borg', 'recreate', '--log-json', '--repo', 'repo'))
|
|
|
|
|
|
module.recreate_archive(
|
|
|
repository='repo',
|
|
@@ -229,12 +271,18 @@ def test_recreate_with_list_config_calls_borg_with_list_flag():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_exclude_flags').and_return(())
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
flexmock(module).should_receive('make_list_filter_flags').and_return('AME+-')
|
|
|
insert_execute_command_mock(
|
|
|
- ('borg', 'recreate', '--list', '--filter', 'AME+-', 'repo::archive')
|
|
|
+ ('borg', 'recreate', '--list', '--filter', 'AME+-', '--repo', 'repo')
|
|
|
)
|
|
|
|
|
|
module.recreate_archive(
|
|
@@ -259,13 +307,19 @@ def test_recreate_with_patterns_from_flag():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_exclude_flags').and_return(())
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
mock_patterns_file = flexmock(name='patterns_file')
|
|
|
flexmock(module).should_receive('write_patterns_file').and_return(mock_patterns_file)
|
|
|
insert_execute_command_mock(
|
|
|
- ('borg', 'recreate', '--patterns-from', 'patterns_file', 'repo::archive')
|
|
|
+ ('borg', 'recreate', '--patterns-from', 'patterns_file', '--repo', 'repo')
|
|
|
)
|
|
|
|
|
|
module.recreate_archive(
|
|
@@ -290,11 +344,17 @@ def test_recreate_with_exclude_flags():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
flexmock(module).should_receive('make_exclude_flags').and_return(('--exclude', 'pattern'))
|
|
|
- insert_execute_command_mock(('borg', 'recreate', '--exclude', 'pattern', 'repo::archive'))
|
|
|
+ insert_execute_command_mock(('borg', 'recreate', '--exclude', 'pattern', '--repo', 'repo'))
|
|
|
|
|
|
module.recreate_archive(
|
|
|
repository='repo',
|
|
@@ -319,10 +379,16 @@ def test_recreate_with_target_flag():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
- insert_execute_command_mock(('borg', 'recreate', '--target', 'new-archive', 'repo::archive'))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
+ insert_execute_command_mock(('borg', 'recreate', '--target', 'new-archive', '--repo', 'repo'))
|
|
|
|
|
|
module.recreate_archive(
|
|
|
repository='repo',
|
|
@@ -347,11 +413,17 @@ def test_recreate_with_comment_flag():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
insert_execute_command_mock(
|
|
|
- ('borg', 'recreate', '--comment', shlex.quote('This is a test comment'), 'repo::archive')
|
|
|
+ ('borg', 'recreate', '--comment', shlex.quote('This is a test comment'), '--repo', 'repo')
|
|
|
)
|
|
|
|
|
|
module.recreate_archive(
|
|
@@ -377,11 +449,17 @@ def test_recreate_with_timestamp_flag():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
insert_execute_command_mock(
|
|
|
- ('borg', 'recreate', '--timestamp', '2023-10-01T12:00:00', 'repo::archive')
|
|
|
+ ('borg', 'recreate', '--timestamp', '2023-10-01T12:00:00', '--repo', 'repo')
|
|
|
)
|
|
|
|
|
|
module.recreate_archive(
|
|
@@ -407,10 +485,16 @@ def test_recreate_with_compression_flag():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
- insert_execute_command_mock(('borg', 'recreate', '--compression', 'lz4', 'repo::archive'))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
+ insert_execute_command_mock(('borg', 'recreate', '--compression', 'lz4', '--repo', 'repo'))
|
|
|
|
|
|
module.recreate_archive(
|
|
|
repository='repo',
|
|
@@ -435,11 +519,17 @@ def test_recreate_with_chunker_params_flag():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
insert_execute_command_mock(
|
|
|
- ('borg', 'recreate', '--chunker-params', '19,23,21,4095', 'repo::archive')
|
|
|
+ ('borg', 'recreate', '--chunker-params', '19,23,21,4095', '--repo', 'repo')
|
|
|
)
|
|
|
|
|
|
module.recreate_archive(
|
|
@@ -465,10 +555,16 @@ def test_recreate_with_recompress_flag():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
- insert_execute_command_mock(('borg', 'recreate', '--recompress', 'always', 'repo::archive'))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
+ insert_execute_command_mock(('borg', 'recreate', '--recompress', 'always', '--repo', 'repo'))
|
|
|
|
|
|
module.recreate_archive(
|
|
|
repository='repo',
|
|
@@ -493,10 +589,16 @@ def test_recreate_with_match_archives_star():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
- insert_execute_command_mock(('borg', 'recreate', 'repo::archive'))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
+ insert_execute_command_mock(('borg', 'recreate', '--repo', 'repo'))
|
|
|
|
|
|
module.recreate_archive(
|
|
|
repository='repo',
|
|
@@ -521,10 +623,16 @@ def test_recreate_with_match_archives_regex():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
- insert_execute_command_mock(('borg', 'recreate', 'repo::archive'))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
+ insert_execute_command_mock(('borg', 'recreate', '--repo', 'repo'))
|
|
|
|
|
|
module.recreate_archive(
|
|
|
repository='repo',
|
|
@@ -549,10 +657,16 @@ def test_recreate_with_match_archives_shell():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
- insert_execute_command_mock(('borg', 'recreate', 'repo::archive'))
|
|
|
+ ).and_return(
|
|
|
+ (
|
|
|
+ '--repo',
|
|
|
+ 'repo',
|
|
|
+ )
|
|
|
+ )
|
|
|
+ insert_execute_command_mock(('borg', 'recreate', '--repo', 'repo'))
|
|
|
|
|
|
module.recreate_archive(
|
|
|
repository='repo',
|
|
@@ -572,22 +686,58 @@ def test_recreate_with_match_archives_shell():
|
|
|
)
|
|
|
|
|
|
|
|
|
-def test_recreate_with_glob_archives_flag():
|
|
|
+def test_recreate_with_match_archives_and_feature_available_calls_borg_with_match_archives():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_exclude_flags').and_return(())
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
- flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(
|
|
|
- ('--glob-archives', 'foo-*')
|
|
|
+ flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').with_args(
|
|
|
+ 'foo-*', None, '1.2.3'
|
|
|
+ ).and_return(('--match-archives', 'foo-*'))
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
+ flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
|
|
+ ('--repo', 'repo')
|
|
|
+ )
|
|
|
+ flexmock(module.borgmatic.borg.flags).should_receive('make_repository_archive_flags').never()
|
|
|
+ insert_execute_command_mock(('borg', 'recreate', '--repo', 'repo', '--match-archives', 'foo-*'))
|
|
|
+
|
|
|
+ module.recreate_archive(
|
|
|
+ repository='repo',
|
|
|
+ archive=None,
|
|
|
+ config={'match_archives': 'foo-*'},
|
|
|
+ local_borg_version='1.2.3',
|
|
|
+ recreate_arguments=flexmock(
|
|
|
+ list=None,
|
|
|
+ target=None,
|
|
|
+ comment=None,
|
|
|
+ timestamp=None,
|
|
|
+ match_archives='foo-*',
|
|
|
+ ),
|
|
|
+ global_arguments=flexmock(dry_run=False, log_json=False),
|
|
|
+ local_path='borg',
|
|
|
+ patterns=None,
|
|
|
+ )
|
|
|
+
|
|
|
+
|
|
|
+def test_recreate_with_archives_flag_and_feature_available_calls_borg_with_match_archives():
|
|
|
+ flexmock(module.borgmatic.borg.create).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
+ flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
+ flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').with_args(
|
|
|
+ 'archive', None, '1.2.3'
|
|
|
+ ).and_return(('--match-archives', 'archive'))
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
|
|
+ flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
|
|
+ ('--repo', 'repo')
|
|
|
+ )
|
|
|
+ flexmock(module.borgmatic.borg.flags).should_receive('make_repository_archive_flags').never()
|
|
|
+ insert_execute_command_mock(
|
|
|
+ ('borg', 'recreate', '--repo', 'repo', '--match-archives', 'archive')
|
|
|
)
|
|
|
- flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
- 'make_repository_archive_flags'
|
|
|
- ).and_return(('repo::archive',))
|
|
|
- insert_execute_command_mock(('borg', 'recreate', '--glob-archives', 'foo-*', 'repo::archive'))
|
|
|
|
|
|
module.recreate_archive(
|
|
|
repository='repo',
|
|
|
archive='archive',
|
|
|
- config={},
|
|
|
+ config={'match_archives': 'foo-*'},
|
|
|
local_borg_version='1.2.3',
|
|
|
recreate_arguments=flexmock(
|
|
|
list=None,
|
|
@@ -602,31 +752,59 @@ def test_recreate_with_glob_archives_flag():
|
|
|
)
|
|
|
|
|
|
|
|
|
-def test_recreate_with_match_archives_flag():
|
|
|
+def test_recreate_with_match_archives_and_feature_not_available_calls_borg_without_match_archives():
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_exclude_flags').and_return(())
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
- flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(
|
|
|
- ('--match-archives', 'sh:foo-*')
|
|
|
+ flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').never()
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(False)
|
|
|
+ flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
|
|
+ ('repo',)
|
|
|
+ )
|
|
|
+ flexmock(module.borgmatic.borg.flags).should_receive('make_repository_archive_flags').never()
|
|
|
+ insert_execute_command_mock(('borg', 'recreate', 'repo'))
|
|
|
+
|
|
|
+ module.recreate_archive(
|
|
|
+ repository='repo',
|
|
|
+ archive=None,
|
|
|
+ config={'match_archives': 'foo-*'},
|
|
|
+ local_borg_version='1.2.3',
|
|
|
+ recreate_arguments=flexmock(
|
|
|
+ list=None,
|
|
|
+ target=None,
|
|
|
+ comment=None,
|
|
|
+ timestamp=None,
|
|
|
+ match_archives='foo-*',
|
|
|
+ ),
|
|
|
+ global_arguments=flexmock(dry_run=False, log_json=False),
|
|
|
+ local_path='borg',
|
|
|
+ patterns=None,
|
|
|
)
|
|
|
+
|
|
|
+
|
|
|
+def test_recreate_with_archives_flags_and_feature_not_available_calls_borg_with_combined_repo_and_archive():
|
|
|
+ flexmock(module.borgmatic.borg.create).should_receive('make_exclude_flags').and_return(())
|
|
|
+ flexmock(module.borgmatic.borg.create).should_receive('write_patterns_file').and_return(None)
|
|
|
+ flexmock(module.borgmatic.borg.create).should_receive('make_list_filter_flags').and_return('')
|
|
|
+ flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').never()
|
|
|
+ flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(False)
|
|
|
flexmock(module.borgmatic.borg.flags).should_receive(
|
|
|
'make_repository_archive_flags'
|
|
|
- ).and_return(('--repo', 'repo', 'archive'))
|
|
|
- insert_execute_command_mock(
|
|
|
- ('borg', 'recreate', '--match-archives', 'sh:foo-*', '--repo', 'repo', 'archive')
|
|
|
- )
|
|
|
+ ).and_return(('repo::archive',))
|
|
|
+ flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').never()
|
|
|
+ insert_execute_command_mock(('borg', 'recreate', 'repo::archive'))
|
|
|
|
|
|
module.recreate_archive(
|
|
|
repository='repo',
|
|
|
archive='archive',
|
|
|
- config={},
|
|
|
- local_borg_version='2.0.0b3',
|
|
|
+ config={'match_archives': 'foo-*'},
|
|
|
+ local_borg_version='1.2.3',
|
|
|
recreate_arguments=flexmock(
|
|
|
list=None,
|
|
|
target=None,
|
|
|
comment=None,
|
|
|
timestamp=None,
|
|
|
- match_archives='sh:foo-*',
|
|
|
+ match_archives='foo-*',
|
|
|
),
|
|
|
global_arguments=flexmock(dry_run=False, log_json=False),
|
|
|
local_path='borg',
|