Merge pull request #1261 from aanand/fix-vars-in-volume-paths
Fix vars in volume paths
(cherry picked from commit 4926f8aef6)
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
Conflicts:
tests/unit/service_test.py
This commit is contained in:
parent
78227c3c06
commit
a467a8a094
5 changed files with 35 additions and 19 deletions
|
|
@ -39,6 +39,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({}, {})
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
import os
|
||||
|
||||
from .. import unittest
|
||||
import mock
|
||||
|
|
@ -301,18 +300,3 @@ class ServiceVolumesTest(unittest.TestCase):
|
|||
self.assertEqual(
|
||||
binding,
|
||||
('/outside', dict(bind='/inside', ro=False)))
|
||||
|
||||
@mock.patch.dict(os.environ)
|
||||
def test_build_volume_binding_with_environ(self):
|
||||
os.environ['VOLUME_PATH'] = '/opt'
|
||||
binding = build_volume_binding(parse_volume_spec('${VOLUME_PATH}:/opt'))
|
||||
self.assertEqual(binding, ('/opt', dict(bind='/opt', ro=False)))
|
||||
|
||||
@mock.patch.dict(os.environ)
|
||||
def test_building_volume_binding_with_home(self):
|
||||
os.environ['HOME'] = '/home/user'
|
||||
binding = build_volume_binding(parse_volume_spec('~:/home/user'))
|
||||
self.assertEqual(
|
||||
binding,
|
||||
('/home/user', dict(bind='/home/user', ro=False)))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue