Fix tests for remaining hooks (#962).
This commit is contained in:
parent
b72b9aaf13
commit
ad14ff3ee5
3 changed files with 40 additions and 24 deletions
|
|
@ -172,7 +172,7 @@ def make_borg_snapshot_pattern(subvolume_path, pattern):
|
|||
else ''
|
||||
)
|
||||
|
||||
written_path = initial_caret + os.path.join(
|
||||
rewritten_path = initial_caret + os.path.join(
|
||||
subvolume_path,
|
||||
f'{BORGMATIC_SNAPSHOT_PREFIX}{os.getpid()}',
|
||||
'.', # Borg 1.4+ "slashdot" hack.
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ def test_dump_data_sources_creates_manifest_file():
|
|||
log_prefix='test',
|
||||
config_paths=('test.yaml',),
|
||||
borgmatic_runtime_directory='/run/borgmatic',
|
||||
source_directories=[],
|
||||
patterns=[],
|
||||
dry_run=False,
|
||||
)
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ def test_dump_data_sources_with_store_config_files_false_does_not_create_manifes
|
|||
log_prefix='test',
|
||||
config_paths=('test.yaml',),
|
||||
borgmatic_runtime_directory='/run/borgmatic',
|
||||
source_directories=[],
|
||||
patterns=[],
|
||||
dry_run=True,
|
||||
)
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ def test_dump_data_sources_with_dry_run_does_not_create_manifest_file():
|
|||
log_prefix='test',
|
||||
config_paths=('test.yaml',),
|
||||
borgmatic_runtime_directory='/run/borgmatic',
|
||||
source_directories=[],
|
||||
patterns=[],
|
||||
dry_run=True,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -92,11 +92,11 @@ def test_get_subvolumes_collects_subvolumes_matching_patterns_from_all_filesyste
|
|||
|
||||
for path in ('/one', '/four'):
|
||||
flexmock(module.borgmatic.hooks.data_source.snapshot).should_receive(
|
||||
'get_contained_directories'
|
||||
).with_args(path, object).and_return((path,))
|
||||
'get_contained_patterns'
|
||||
).with_args(path, object).and_return((Pattern(path),))
|
||||
for path in ('/two', '/three'):
|
||||
flexmock(module.borgmatic.hooks.data_source.snapshot).should_receive(
|
||||
'get_contained_directories'
|
||||
'get_contained_patterns'
|
||||
).with_args(path, object).and_return(())
|
||||
|
||||
assert module.get_subvolumes(
|
||||
|
|
@ -125,8 +125,8 @@ def test_get_subvolumes_without_patterns_collects_all_subvolumes_from_all_filesy
|
|||
|
||||
for path in ('/one', '/two', '/three', '/four'):
|
||||
flexmock(module.borgmatic.hooks.data_source.snapshot).should_receive(
|
||||
'get_contained_directories'
|
||||
).with_args(path, object).and_return((path,))
|
||||
'get_contained_patterns'
|
||||
).with_args(path, object).and_return((Pattern(path),))
|
||||
|
||||
assert module.get_subvolumes('btrfs', 'findmnt') == (
|
||||
module.Subvolume('/four', contained_patterns=(Pattern('/four'),)),
|
||||
|
|
@ -233,14 +233,20 @@ def test_dump_data_sources_snapshots_each_subvolume_and_updates_patterns():
|
|||
assert patterns == [
|
||||
Pattern('/foo'),
|
||||
Pattern('/mnt/subvol1/.borgmatic-1234/mnt/subvol1'),
|
||||
Pattern(
|
||||
'/mnt/subvol1/.borgmatic-1234/mnt/subvol1/.borgmatic-1234',
|
||||
Pattern_type.EXCLUDE,
|
||||
Pattern_style.FNMATCH,
|
||||
),
|
||||
Pattern('/mnt/subvol2/.borgmatic-1234/mnt/subvol2'),
|
||||
Pattern(
|
||||
'/mnt/subvol2/.borgmatic-1234/mnt/subvol2/.borgmatic-1234',
|
||||
Pattern_type.EXCLUDE,
|
||||
Pattern_style.FNMATCH,
|
||||
),
|
||||
]
|
||||
assert config == {
|
||||
'btrfs': {},
|
||||
'exclude_patterns': [
|
||||
'/mnt/subvol1/.borgmatic-1234/mnt/subvol1/.borgmatic-1234',
|
||||
'/mnt/subvol2/.borgmatic-1234/mnt/subvol2/.borgmatic-1234',
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -285,14 +291,16 @@ def test_dump_data_sources_uses_custom_btrfs_command_in_commands():
|
|||
assert patterns == [
|
||||
Pattern('/foo'),
|
||||
Pattern('/mnt/subvol1/.borgmatic-1234/mnt/subvol1'),
|
||||
Pattern(
|
||||
'/mnt/subvol1/.borgmatic-1234/mnt/subvol1/.borgmatic-1234',
|
||||
Pattern_type.EXCLUDE,
|
||||
Pattern_style.FNMATCH,
|
||||
),
|
||||
]
|
||||
assert config == {
|
||||
'btrfs': {
|
||||
'btrfs_command': '/usr/local/bin/btrfs',
|
||||
},
|
||||
'exclude_patterns': [
|
||||
'/mnt/subvol1/.borgmatic-1234/mnt/subvol1/.borgmatic-1234',
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -339,14 +347,16 @@ def test_dump_data_sources_uses_custom_findmnt_command_in_commands():
|
|||
assert patterns == [
|
||||
Pattern('/foo'),
|
||||
Pattern('/mnt/subvol1/.borgmatic-1234/mnt/subvol1'),
|
||||
Pattern(
|
||||
'/mnt/subvol1/.borgmatic-1234/mnt/subvol1/.borgmatic-1234',
|
||||
Pattern_type.EXCLUDE,
|
||||
Pattern_style.FNMATCH,
|
||||
)
|
||||
]
|
||||
assert config == {
|
||||
'btrfs': {
|
||||
'findmnt_command': '/usr/local/bin/findmnt',
|
||||
},
|
||||
'exclude_patterns': [
|
||||
'/mnt/subvol1/.borgmatic-1234/mnt/subvol1/.borgmatic-1234',
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -466,15 +476,21 @@ def test_dump_data_sources_snapshots_adds_to_existing_exclude_patterns():
|
|||
assert patterns == [
|
||||
Pattern('/foo'),
|
||||
Pattern('/mnt/subvol1/.borgmatic-1234/mnt/subvol1'),
|
||||
Pattern(
|
||||
'/mnt/subvol1/.borgmatic-1234/mnt/subvol1/.borgmatic-1234',
|
||||
Pattern_type.EXCLUDE,
|
||||
Pattern_style.FNMATCH,
|
||||
),
|
||||
Pattern('/mnt/subvol2/.borgmatic-1234/mnt/subvol2'),
|
||||
Pattern(
|
||||
'/mnt/subvol2/.borgmatic-1234/mnt/subvol2/.borgmatic-1234',
|
||||
Pattern_type.EXCLUDE,
|
||||
Pattern_style.FNMATCH,
|
||||
),
|
||||
]
|
||||
assert config == {
|
||||
'btrfs': {},
|
||||
'exclude_patterns': [
|
||||
'/bar',
|
||||
'/mnt/subvol1/.borgmatic-1234/mnt/subvol1/.borgmatic-1234',
|
||||
'/mnt/subvol2/.borgmatic-1234/mnt/subvol2/.borgmatic-1234',
|
||||
],
|
||||
'exclude_patterns': ['/bar'],
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue