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:
Aanand Prasad 2015-03-23 11:31:30 -07:00
parent b7046777d1
commit 276e43ca6b
2 changed files with 27 additions and 1 deletions

View File

@ -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):

View File

@ -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 =[