Merge pull request #2350 from dnephin/remove_name_from_schema
Remove name field from the config schema
This commit is contained in:
commit
a746d673b1
6 changed files with 74 additions and 69 deletions
|
|
@ -9,6 +9,7 @@ from .. import unittest
|
|||
from compose.cli.docker_client import docker_client
|
||||
from compose.config.config import process_service
|
||||
from compose.config.config import resolve_environment
|
||||
from compose.config.config import ServiceConfig
|
||||
from compose.const import LABEL_PROJECT
|
||||
from compose.progress_stream import stream_output
|
||||
from compose.service import Service
|
||||
|
|
@ -43,15 +44,13 @@ class DockerClientTestCase(unittest.TestCase):
|
|||
if 'command' not in kwargs:
|
||||
kwargs['command'] = ["top"]
|
||||
|
||||
# TODO: remove this once #2299 is fixed
|
||||
kwargs['name'] = name
|
||||
|
||||
options = process_service('.', kwargs)
|
||||
service_config = ServiceConfig('.', None, name, kwargs)
|
||||
options = process_service(service_config)
|
||||
options['environment'] = resolve_environment('.', kwargs)
|
||||
labels = options.setdefault('labels', {})
|
||||
labels['com.docker.compose.test-name'] = self.id()
|
||||
|
||||
return Service(client=self.client, project='composetest', **options)
|
||||
return Service(name, client=self.client, project='composetest', **options)
|
||||
|
||||
def check_build(self, *args, **kwargs):
|
||||
kwargs.setdefault('rm', True)
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@ def make_service_dict(name, service_dict, working_dir, filename=None):
|
|||
"""
|
||||
Test helper function to construct a ServiceExtendsResolver
|
||||
"""
|
||||
resolver = config.ServiceExtendsResolver(
|
||||
resolver = config.ServiceExtendsResolver(config.ServiceConfig(
|
||||
working_dir=working_dir,
|
||||
filename=filename,
|
||||
service_name=name,
|
||||
service_dict=service_dict)
|
||||
return config.process_service(working_dir, resolver.run())
|
||||
name=name,
|
||||
config=service_dict))
|
||||
return config.process_service(resolver.run())
|
||||
|
||||
|
||||
def service_sort(services):
|
||||
|
|
@ -77,8 +77,8 @@ class ConfigTest(unittest.TestCase):
|
|||
)
|
||||
|
||||
def test_config_invalid_service_names(self):
|
||||
with self.assertRaises(ConfigurationError):
|
||||
for invalid_name in ['?not?allowed', ' ', '', '!', '/', '\xe2']:
|
||||
for invalid_name in ['?not?allowed', ' ', '', '!', '/', '\xe2']:
|
||||
with pytest.raises(ConfigurationError):
|
||||
config.load(
|
||||
build_config_details(
|
||||
{invalid_name: {'image': 'busybox'}},
|
||||
|
|
@ -87,6 +87,16 @@ class ConfigTest(unittest.TestCase):
|
|||
)
|
||||
)
|
||||
|
||||
def test_load_with_invalid_field_name(self):
|
||||
config_details = build_config_details(
|
||||
{'web': {'image': 'busybox', 'name': 'bogus'}},
|
||||
'working_dir',
|
||||
'filename.yml')
|
||||
with pytest.raises(ConfigurationError) as exc:
|
||||
config.load(config_details)
|
||||
error_msg = "Unsupported config option for 'web' service: 'name'"
|
||||
assert error_msg in exc.exconly()
|
||||
|
||||
def test_config_integer_service_name_raise_validation_error(self):
|
||||
expected_error_msg = "Service name: 1 needs to be a string, eg '1'"
|
||||
with self.assertRaisesRegexp(ConfigurationError, expected_error_msg):
|
||||
|
|
@ -651,7 +661,7 @@ class VolumeConfigTest(unittest.TestCase):
|
|||
|
||||
def test_volume_path_with_non_ascii_directory(self):
|
||||
volume = u'/Füü/data:/data'
|
||||
container_path = config.resolve_volume_path(".", volume, "test")
|
||||
container_path = config.resolve_volume_path(".", volume)
|
||||
self.assertEqual(container_path, volume)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue