Test that you can set the default network to be external

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
Aanand Prasad 2016-01-19 10:57:12 +00:00
parent fbee4ce4b3
commit 7442b416e8
2 changed files with 35 additions and 0 deletions

View File

@ -528,6 +528,29 @@ class CLITestCase(DockerClientTestCase):
container = self.project.containers()[0] container = self.project.containers()[0]
assert sorted(list(container.get('NetworkSettings.Networks'))) == sorted(network_names) assert sorted(list(container.get('NetworkSettings.Networks'))) == sorted(network_names)
@v2_only()
def test_up_with_external_default_network(self):
filename = 'external-default.yml'
self.base_dir = 'tests/fixtures/networks'
self._project = get_project(self.base_dir, [filename])
result = self.dispatch(['-f', filename, 'up', '-d'], returncode=1)
assert 'declared as external, but could not be found' in result.stderr
networks = [
n['Name'] for n in self.client.networks()
if n['Name'].startswith('{}_'.format(self.project.name))
]
assert not networks
network_name = 'composetest_external_network'
self.client.create_network(network_name)
self.dispatch(['-f', filename, 'up', '-d'])
container = self.project.containers()[0]
assert list(container.get('NetworkSettings.Networks')) == [network_name]
@v2_only() @v2_only()
def test_up_no_services(self): def test_up_no_services(self):
self.base_dir = 'tests/fixtures/no-services' self.base_dir = 'tests/fixtures/no-services'

View File

@ -0,0 +1,12 @@
version: 2
services:
simple:
image: busybox:latest
command: top
another:
image: busybox:latest
command: top
networks:
default:
external:
name: composetest_external_network