Interpolate environment variables
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
31ac3ce22a
commit
8b5bd945d0
9 changed files with 235 additions and 35 deletions
|
|
@ -488,6 +488,21 @@ class CLITestCase(DockerClientTestCase):
|
|||
self.assertEqual(len(containers), 1)
|
||||
self.assertIn("FOO=1", containers[0].get('Config.Env'))
|
||||
|
||||
@patch.dict(os.environ)
|
||||
def test_home_and_env_var_in_volume_path(self):
|
||||
os.environ['VOLUME_NAME'] = 'my-volume'
|
||||
os.environ['HOME'] = '/tmp/home-dir'
|
||||
expected_host_path = os.path.join(os.environ['HOME'], os.environ['VOLUME_NAME'])
|
||||
|
||||
self.command.base_dir = 'tests/fixtures/volume-path-interpolation'
|
||||
self.command.dispatch(['up', '-d'], None)
|
||||
|
||||
container = self.project.containers(stopped=True)[0]
|
||||
actual_host_path = container.get('Volumes')['/container-path']
|
||||
components = actual_host_path.split('/')
|
||||
self.assertTrue(components[-2:] == ['home-dir', 'my-volume'],
|
||||
msg="Last two components differ: %s, %s" % (actual_host_path, expected_host_path))
|
||||
|
||||
def test_up_with_extends(self):
|
||||
self.command.base_dir = 'tests/fixtures/extends'
|
||||
self.command.dispatch(['up', '-d'], None)
|
||||
|
|
|
|||
|
|
@ -273,24 +273,6 @@ class ServiceTest(DockerClientTestCase):
|
|||
|
||||
self.assertEqual(service.containers(stopped=False), [new_container])
|
||||
|
||||
@patch.dict(os.environ)
|
||||
def test_create_container_with_home_and_env_var_in_volume_path(self):
|
||||
os.environ['VOLUME_NAME'] = 'my-volume'
|
||||
os.environ['HOME'] = '/tmp/home-dir'
|
||||
expected_host_path = os.path.join(os.environ['HOME'], os.environ['VOLUME_NAME'])
|
||||
|
||||
host_path = '~/${VOLUME_NAME}'
|
||||
container_path = '/container-path'
|
||||
|
||||
service = self.create_service('db', volumes=['%s:%s' % (host_path, container_path)])
|
||||
container = service.create_container()
|
||||
service.start_container(container)
|
||||
|
||||
actual_host_path = container.get('Volumes')[container_path]
|
||||
components = actual_host_path.split('/')
|
||||
self.assertTrue(components[-2:] == ['home-dir', 'my-volume'],
|
||||
msg="Last two components differ: %s, %s" % (actual_host_path, expected_host_path))
|
||||
|
||||
def test_create_container_with_volumes_from(self):
|
||||
volume_service = self.create_service('data')
|
||||
volume_container_1 = volume_service.create_container()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue