Only parse "--override" values as complex data types when they're for options of those types (#779).
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -4,19 +4,24 @@ from borgmatic.config import override as module
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'value,expected_result',
|
||||
'value,expected_result,option_type',
|
||||
(
|
||||
('thing', 'thing'),
|
||||
('33', 33),
|
||||
('33b', '33b'),
|
||||
('true', True),
|
||||
('false', False),
|
||||
('[foo]', ['foo']),
|
||||
('[foo, bar]', ['foo', 'bar']),
|
||||
('thing', 'thing', 'string'),
|
||||
('33', 33, 'integer'),
|
||||
('33', '33', 'string'),
|
||||
('33b', '33b', 'integer'),
|
||||
('33b', '33b', 'string'),
|
||||
('true', True, 'boolean'),
|
||||
('false', False, 'boolean'),
|
||||
('true', 'true', 'string'),
|
||||
('[foo]', ['foo'], 'array'),
|
||||
('[foo]', '[foo]', 'string'),
|
||||
('[foo, bar]', ['foo', 'bar'], 'array'),
|
||||
('[foo, bar]', '[foo, bar]', 'string'),
|
||||
),
|
||||
)
|
||||
def test_convert_value_type_coerces_values(value, expected_result):
|
||||
assert module.convert_value_type(value) == expected_result
|
||||
def test_convert_value_type_coerces_values(value, expected_result, option_type):
|
||||
assert module.convert_value_type(value, option_type) == expected_result
|
||||
|
||||
|
||||
def test_apply_overrides_updates_config():
|
||||
@@ -25,16 +30,23 @@ def test_apply_overrides_updates_config():
|
||||
'other_section.thing=value2',
|
||||
'section.nested.key=value3',
|
||||
'new.foo=bar',
|
||||
'new.mylist=[baz]',
|
||||
'new.nonlist=[quux]',
|
||||
]
|
||||
config = {
|
||||
'section': {'key': 'value', 'other': 'other_value'},
|
||||
'other_section': {'thing': 'thing_value'},
|
||||
}
|
||||
schema = {
|
||||
'properties': {
|
||||
'new': {'properties': {'mylist': {'type': 'array'}, 'nonlist': {'type': 'string'}}}
|
||||
}
|
||||
}
|
||||
|
||||
module.apply_overrides(config, raw_overrides)
|
||||
module.apply_overrides(config, schema, raw_overrides)
|
||||
|
||||
assert config == {
|
||||
'section': {'key': 'value1', 'other': 'other_value', 'nested': {'key': 'value3'}},
|
||||
'other_section': {'thing': 'value2'},
|
||||
'new': {'foo': 'bar'},
|
||||
'new': {'foo': 'bar', 'mylist': ['baz'], 'nonlist': '[quux]'},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user