Normalize external_name

Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
Joffrey F 2016-01-13 12:07:08 -08:00
commit d601199eb5
5 changed files with 22 additions and 14 deletions

View file

@ -687,7 +687,9 @@ class ProjectTest(DockerClientTestCase):
'name': 'web',
'image': 'busybox:latest',
'command': 'top'
}], volumes={vol_name: {'external': True}}
}], volumes={
vol_name: {'external': True, 'external_name': vol_name}
}
)
project = Project.from_config(
name='composetest',
@ -706,7 +708,9 @@ class ProjectTest(DockerClientTestCase):
'name': 'web',
'image': 'busybox:latest',
'command': 'top'
}], volumes={vol_name: {'external': True}}
}], volumes={
vol_name: {'external': True, 'external_name': vol_name}
}
)
project = Project.from_config(
name='composetest',

View file

@ -18,10 +18,12 @@ class VolumeTest(DockerClientTestCase):
except DockerException:
pass
def create_volume(self, name, driver=None, opts=None, external=False):
def create_volume(self, name, driver=None, opts=None, external=None):
if external and isinstance(external, bool):
external = name
vol = Volume(
self.client, 'composetest', name, driver=driver, driver_opts=opts,
external=external
external_name=external
)
self.tmp_volumes.append(vol)
return vol
@ -66,7 +68,7 @@ class VolumeTest(DockerClientTestCase):
def test_external_aliased_volume(self):
alias_name = 'composetest_alias01'
vol = self.create_volume('volume01', external={'name': alias_name})
vol = self.create_volume('volume01', external=alias_name)
assert vol.external is True
assert vol.full_name == alias_name
vol.create()
@ -86,7 +88,7 @@ class VolumeTest(DockerClientTestCase):
assert vol.exists() is True
def test_exists_external_aliased(self):
vol = self.create_volume('volume01', external={'name': 'composetest_alias01'})
vol = self.create_volume('volume01', external='composetest_alias01')
assert vol.exists() is False
vol.create()
assert vol.exists() is True