diff --git a/tests/unit/config/test_normalize.py b/tests/unit/config/test_normalize.py index fe9e7ac..1d61a77 100644 --- a/tests/unit/config/test_normalize.py +++ b/tests/unit/config/test_normalize.py @@ -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'] + } + }, + ) diff --git a/tests/unit/config/test_validate.py b/tests/unit/config/test_validate.py index 2852722..327a2b4 100644 --- a/tests/unit/config/test_validate.py +++ b/tests/unit/config/test_validate.py @@ -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']}}}