@@ -123,6 +123,24 @@ def test_create_container_with_specified_volume(self):
123123 self .assertTrue (path .basename (actual_host_path ) == path .basename (host_path ),
124124 msg = ("Last component differs: %s, %s" % (actual_host_path , host_path )))
125125
126+ @mock .patch .dict (os .environ )
127+ def test_create_container_with_home_and_env_var_in_volume_path (self ):
128+ os .environ ['VOLUME_NAME' ] = 'my-volume'
129+ os .environ ['HOME' ] = '/tmp/home-dir'
130+ expected_host_path = os .path .join (os .environ ['HOME' ], os .environ ['VOLUME_NAME' ])
131+
132+ host_path = '~/${VOLUME_NAME}'
133+ container_path = '/container-path'
134+
135+ service = self .create_service ('db' , volumes = ['%s:%s' % (host_path , container_path )])
136+ container = service .create_container ()
137+ service .start_container (container )
138+
139+ actual_host_path = container .get ('Volumes' )[container_path ]
140+ components = actual_host_path .split ('/' )
141+ self .assertTrue (components [- 2 :] == ['home-dir' , 'my-volume' ],
142+ msg = "Last two components differ: %s, %s" % (actual_host_path , expected_host_path ))
143+
126144 def test_create_container_with_volumes_from (self ):
127145 volume_service = self .create_service ('data' )
128146 volume_container_1 = volume_service .create_container ()
0 commit comments