mirror of https://github.com/docker/compose.git
Fix service dict merging when only one dict has a volumes key
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
b7046777d1
commit
276e43ca6b
|
@ -318,7 +318,10 @@ def merge_volumes(base, override):
|
|||
|
||||
|
||||
def dict_from_volumes(volumes):
|
||||
return dict(split_volume(v) for v in volumes)
|
||||
if volumes:
|
||||
return dict(split_volume(v) for v in volumes)
|
||||
else:
|
||||
return {}
|
||||
|
||||
|
||||
def split_volume(volume):
|
||||
|
|
|
@ -39,6 +39,29 @@ class ConfigTest(unittest.TestCase):
|
|||
config.make_service_dict('foo', {'ports': ['8000']})
|
||||
|
||||
|
||||
class MergeTest(unittest.TestCase):
|
||||
def test_merge_volumes(self):
|
||||
service_dict = config.merge_service_dicts({}, {})
|
||||
self.assertNotIn('volumes', service_dict)
|
||||
|
||||
service_dict = config.merge_service_dicts({
|
||||
'volumes': ['/foo:/data'],
|
||||
}, {})
|
||||
self.assertEqual(service_dict['volumes'], ['/foo:/data'])
|
||||
|
||||
service_dict = config.merge_service_dicts({}, {
|
||||
'volumes': ['/bar:/data'],
|
||||
})
|
||||
self.assertEqual(service_dict['volumes'], ['/bar:/data'])
|
||||
|
||||
service_dict = config.merge_service_dicts({
|
||||
'volumes': ['/foo:/data'],
|
||||
}, {
|
||||
'volumes': ['/bar:/data'],
|
||||
})
|
||||
self.assertEqual(service_dict['volumes'], ['/bar:/data'])
|
||||
|
||||
|
||||
class EnvTest(unittest.TestCase):
|
||||
def test_parse_environment_as_list(self):
|
||||
environment =[
|
||||
|
|
Loading…
Reference in New Issue