Fixes #2008 - re-use list_or_dict schema for all the types
At the same time, moves extra_hosts validation to the config module. Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
12b82a20ff
commit
efec2aae6c
8 changed files with 90 additions and 88 deletions
|
|
@ -32,7 +32,7 @@ def service_sort(services):
|
|||
return sorted(services, key=itemgetter('name'))
|
||||
|
||||
|
||||
def build_config_details(contents, working_dir, filename):
|
||||
def build_config_details(contents, working_dir='working_dir', filename='filename.yml'):
|
||||
return config.ConfigDetails(
|
||||
working_dir,
|
||||
[config.ConfigFile(filename, contents)])
|
||||
|
|
@ -512,6 +512,29 @@ class ConfigTest(unittest.TestCase):
|
|||
|
||||
assert 'line 3, column 32' in exc.exconly()
|
||||
|
||||
def test_validate_extra_hosts_invalid(self):
|
||||
with pytest.raises(ConfigurationError) as exc:
|
||||
config.load(build_config_details({
|
||||
'web': {
|
||||
'image': 'alpine',
|
||||
'extra_hosts': "www.example.com: 192.168.0.17",
|
||||
}
|
||||
}))
|
||||
assert "'extra_hosts' contains an invalid type" in exc.exconly()
|
||||
|
||||
def test_validate_extra_hosts_invalid_list(self):
|
||||
with pytest.raises(ConfigurationError) as exc:
|
||||
config.load(build_config_details({
|
||||
'web': {
|
||||
'image': 'alpine',
|
||||
'extra_hosts': [
|
||||
{'www.example.com': '192.168.0.17'},
|
||||
{'api.example.com': '192.168.0.18'}
|
||||
],
|
||||
}
|
||||
}))
|
||||
assert "which is an invalid type" in exc.exconly()
|
||||
|
||||
|
||||
class InterpolationTest(unittest.TestCase):
|
||||
@mock.patch.dict(os.environ)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue