mirror of
https://github.com/docker/compose.git
synced 2025-07-26 07:04:32 +02:00
Replace service tests with config tests
We validate the config against our schema before a service is created so checking whether a service name is valid at time of instantiation of the Service class is not needed. Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
parent
da36ee7cbc
commit
76e6029f21
@ -59,6 +59,27 @@ class ConfigTest(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
make_service_dict('foo', {'ports': ['8000']}, 'tests/')
|
make_service_dict('foo', {'ports': ['8000']}, 'tests/')
|
||||||
|
|
||||||
|
def test_config_invalid_service_names(self):
|
||||||
|
with self.assertRaises(config.ConfigurationError):
|
||||||
|
for invalid_name in ['?not?allowed', ' ', '', '!', '/', '\xe2']:
|
||||||
|
config.load(
|
||||||
|
config.ConfigDetails(
|
||||||
|
{invalid_name: {'image': 'busybox'}},
|
||||||
|
'working_dir',
|
||||||
|
'filename.yml'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_config_valid_service_names(self):
|
||||||
|
for valid_name in ['_', '-', '.__.', '_what-up.', 'what_.up----', 'whatup']:
|
||||||
|
config.load(
|
||||||
|
config.ConfigDetails(
|
||||||
|
{valid_name: {'image': 'busybox'}},
|
||||||
|
'tests/fixtures/extends',
|
||||||
|
'common.yml'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class InterpolationTest(unittest.TestCase):
|
class InterpolationTest(unittest.TestCase):
|
||||||
@mock.patch.dict(os.environ)
|
@mock.patch.dict(os.environ)
|
||||||
|
@ -29,25 +29,6 @@ class ServiceTest(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.mock_client = mock.create_autospec(docker.Client)
|
self.mock_client = mock.create_autospec(docker.Client)
|
||||||
|
|
||||||
def test_name_validations(self):
|
|
||||||
self.assertRaises(ConfigError, lambda: Service(name='', image='foo'))
|
|
||||||
|
|
||||||
self.assertRaises(ConfigError, lambda: Service(name=' ', image='foo'))
|
|
||||||
self.assertRaises(ConfigError, lambda: Service(name='/', image='foo'))
|
|
||||||
self.assertRaises(ConfigError, lambda: Service(name='!', image='foo'))
|
|
||||||
self.assertRaises(ConfigError, lambda: Service(name='\xe2', image='foo'))
|
|
||||||
|
|
||||||
Service('a', image='foo')
|
|
||||||
Service('foo', image='foo')
|
|
||||||
Service('foo-bar', image='foo')
|
|
||||||
Service('foo.bar', image='foo')
|
|
||||||
Service('foo_bar', image='foo')
|
|
||||||
Service('_', image='foo')
|
|
||||||
Service('___', image='foo')
|
|
||||||
Service('-', image='foo')
|
|
||||||
Service('--', image='foo')
|
|
||||||
Service('.__.', image='foo')
|
|
||||||
|
|
||||||
def test_project_validation(self):
|
def test_project_validation(self):
|
||||||
self.assertRaises(ConfigError, lambda: Service(name='foo', project='>', image='foo'))
|
self.assertRaises(ConfigError, lambda: Service(name='foo', project='>', image='foo'))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user