mirror of
https://github.com/docker/compose.git
synced 2025-07-06 13:24:25 +02:00
Tweak and test warning shown when version is a dict
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
f081376067
commit
8024f2f09e
@ -138,9 +138,9 @@ class ConfigFile(namedtuple('_ConfigFile', 'filename config')):
|
|||||||
version = self.config['version']
|
version = self.config['version']
|
||||||
|
|
||||||
if isinstance(version, dict):
|
if isinstance(version, dict):
|
||||||
log.warn("Unexpected type for field 'version', in file {} assuming "
|
log.warn('Unexpected type for "version" key in "{}". Assuming '
|
||||||
"version is the name of a service, and defaulting to "
|
'"version" is the name of a service, and defaulting to '
|
||||||
"Compose file version 1".format(self.filename))
|
'Compose file version 1.'.format(self.filename))
|
||||||
return V1
|
return V1
|
||||||
|
|
||||||
if not isinstance(version, six.string_types):
|
if not isinstance(version, six.string_types):
|
||||||
|
@ -232,6 +232,7 @@ class ConfigTest(unittest.TestCase):
|
|||||||
assert volumes['other'] == {}
|
assert volumes['other'] == {}
|
||||||
|
|
||||||
def test_load_service_with_name_version(self):
|
def test_load_service_with_name_version(self):
|
||||||
|
with mock.patch('compose.config.config.log') as mock_logging:
|
||||||
config_data = config.load(
|
config_data = config.load(
|
||||||
build_config_details({
|
build_config_details({
|
||||||
'version': {
|
'version': {
|
||||||
@ -239,6 +240,10 @@ class ConfigTest(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
}, 'working_dir', 'filename.yml')
|
}, 'working_dir', 'filename.yml')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
assert 'Unexpected type for "version" key in "filename.yml"' \
|
||||||
|
in mock_logging.warn.call_args[0][0]
|
||||||
|
|
||||||
service_dicts = config_data.services
|
service_dicts = config_data.services
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
service_sort(service_dicts),
|
service_sort(service_dicts),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user