Fix home directory and env expansion in volume paths
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
219751abc7
commit
fd568b389d
5 changed files with 35 additions and 18 deletions
|
|
@ -40,6 +40,20 @@ class ConfigTest(unittest.TestCase):
|
|||
config.make_service_dict('foo', {'ports': ['8000']})
|
||||
|
||||
|
||||
class VolumePathTest(unittest.TestCase):
|
||||
@mock.patch.dict(os.environ)
|
||||
def test_volume_binding_with_environ(self):
|
||||
os.environ['VOLUME_PATH'] = '/host/path'
|
||||
d = config.make_service_dict('foo', {'volumes': ['${VOLUME_PATH}:/container/path']}, working_dir='.')
|
||||
self.assertEqual(d['volumes'], ['/host/path:/container/path'])
|
||||
|
||||
@mock.patch.dict(os.environ)
|
||||
def test_volume_binding_with_home(self):
|
||||
os.environ['HOME'] = '/home/user'
|
||||
d = config.make_service_dict('foo', {'volumes': ['~:/container/path']}, working_dir='.')
|
||||
self.assertEqual(d['volumes'], ['/home/user:/container/path'])
|
||||
|
||||
|
||||
class MergeVolumesTest(unittest.TestCase):
|
||||
def test_empty(self):
|
||||
service_dict = config.merge_service_dicts({}, {})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue