add tests for repo labels
This commit is contained in:
parent
ec9def4e71
commit
b336b9bedf
2 changed files with 37 additions and 0 deletions
|
@ -92,6 +92,21 @@ from borgmatic.config import normalize as module
|
|||
{'location': {'repositories': [{'path': '/repo'}]}},
|
||||
False,
|
||||
),
|
||||
(
|
||||
{'location': {'repositories': [{'path': 'foo@bar:/repo', 'label': 'foo'}]}},
|
||||
{'location': {'repositories': [{'path': 'ssh://foo@bar/repo', 'label': 'foo'}]}},
|
||||
True,
|
||||
),
|
||||
(
|
||||
{'location': {'repositories': [{'path': 'file:///repo', 'label': 'foo'}]}},
|
||||
{'location': {'repositories': [{'path': '/repo', 'label': 'foo'}]}},
|
||||
False,
|
||||
),
|
||||
(
|
||||
{'location': {'repositories': [{'path': '/repo', 'label': 'foo'}]}},
|
||||
{'location': {'repositories': [{'path': '/repo', 'label': 'foo'}]}},
|
||||
False,
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_normalize_applies_hard_coded_normalization_to_config(
|
||||
|
@ -105,3 +120,15 @@ def test_normalize_applies_hard_coded_normalization_to_config(
|
|||
assert logs
|
||||
else:
|
||||
assert logs == []
|
||||
|
||||
|
||||
def test_normalize_raises_error_if_repository_data_is_not_consistent():
|
||||
with pytest.raises(TypeError):
|
||||
module.normalize(
|
||||
'test.yaml',
|
||||
{
|
||||
'location': {
|
||||
'repositories': [{'path': 'foo@bar:/repo', 'label': 'foo'}, 'file:///repo']
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
|
@ -121,6 +121,16 @@ def test_guard_configuration_contains_repository_does_not_raise_when_repository_
|
|||
)
|
||||
|
||||
|
||||
def test_guard_configuration_contains_repository_does_not_raise_when_repository_label_in_config():
|
||||
|
||||
module.guard_configuration_contains_repository(
|
||||
repository='repo',
|
||||
configurations={
|
||||
'config.yaml': {'location': {'repositories': [{'path': 'foo/bar', 'label': 'repo'}]}}
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def test_guard_configuration_contains_repository_does_not_raise_when_repository_not_given():
|
||||
module.guard_configuration_contains_repository(
|
||||
repository=None, configurations={'config.yaml': {'location': {'repositories': ['repo']}}}
|
||||
|
|
Loading…
Reference in a new issue