mirror of https://github.com/docker/compose.git
test create from config with duplicate mount points
Signed-off-by: Collins Abitekaniza <abtcolns@gmail.com>
This commit is contained in:
parent
d980d170a6
commit
47ff8d710c
|
@ -8,7 +8,7 @@ import os
|
|||
import string
|
||||
import sys
|
||||
from collections import namedtuple
|
||||
from operator import itemgetter, attrgetter
|
||||
from operator import attrgetter
|
||||
|
||||
import six
|
||||
import yaml
|
||||
|
@ -844,9 +844,9 @@ def finalize_service_volumes(service_dict, environment):
|
|||
duplicate_mounts.append(mount.repr())
|
||||
|
||||
if duplicate_mounts:
|
||||
raise ConfigurationError("Duplicate mount points: volumes [%s]" % (
|
||||
raise ConfigurationError("Duplicate mount points: [%s]" % (
|
||||
', '.join(duplicate_mounts)))
|
||||
|
||||
|
||||
service_dict['volumes'] = finalized_volumes
|
||||
|
||||
return service_dict
|
||||
|
|
|
@ -9,7 +9,6 @@ import sys
|
|||
from collections import namedtuple
|
||||
from collections import OrderedDict
|
||||
from operator import attrgetter
|
||||
from operator import itemgetter
|
||||
|
||||
import enum
|
||||
import six
|
||||
|
|
|
@ -3071,6 +3071,41 @@ class ConfigTest(unittest.TestCase):
|
|||
)
|
||||
config.load(config_details)
|
||||
|
||||
def test_config_duplicate_mount_points(self):
|
||||
config1 = build_config_details(
|
||||
{
|
||||
'version': '3.5',
|
||||
'services': {
|
||||
'web': {
|
||||
'image': 'busybox',
|
||||
'volumes': ['/tmp/foo:/tmp/foo', '/tmp/foo:/tmp/foo:rw']
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
config2 = build_config_details(
|
||||
{
|
||||
'version': '3.5',
|
||||
'services': {
|
||||
'web': {
|
||||
'image': 'busybox',
|
||||
'volumes': ['/x:/y', '/z:/y']
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
with self.assertRaises(ConfigurationError) as e:
|
||||
config.load(config1)
|
||||
self.assertEquals(str(e.exception), 'Duplicate mount points: [%s]' % (
|
||||
', '.join(['/tmp/foo:/tmp/foo:rw']*2)))
|
||||
|
||||
with self.assertRaises(ConfigurationError) as e:
|
||||
config.load(config2)
|
||||
self.assertEquals(str(e.exception), 'Duplicate mount points: [%s]' % (
|
||||
', '.join(['/x:/y:rw', '/z:/y:rw'])))
|
||||
|
||||
|
||||
class NetworkModeTest(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue