Make volume host paths relative to file, merge volumes when extending
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
4c582e4352
commit
37efdb1f8b
5 changed files with 80 additions and 12 deletions
5
tests/fixtures/volume-path/common/services.yml
vendored
Normal file
5
tests/fixtures/volume-path/common/services.yml
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
db:
|
||||
image: busybox
|
||||
volumes:
|
||||
- ./foo:/foo
|
||||
- ./bar:/bar
|
||||
6
tests/fixtures/volume-path/docker-compose.yml
vendored
Normal file
6
tests/fixtures/volume-path/docker-compose.yml
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
db:
|
||||
extends:
|
||||
file: common/services.yml
|
||||
service: db
|
||||
volumes:
|
||||
- ./bar:/bar
|
||||
|
|
@ -7,18 +7,19 @@ from .testcases import DockerClientTestCase
|
|||
|
||||
class ProjectTest(DockerClientTestCase):
|
||||
def test_volumes_from_service(self):
|
||||
service_dicts = config.from_dictionary({
|
||||
'data': {
|
||||
'image': 'busybox:latest',
|
||||
'volumes': ['/var/data'],
|
||||
},
|
||||
'db': {
|
||||
'image': 'busybox:latest',
|
||||
'volumes_from': ['data'],
|
||||
},
|
||||
}, working_dir='.')
|
||||
project = Project.from_dicts(
|
||||
name='composetest',
|
||||
service_dicts=config.from_dictionary({
|
||||
'data': {
|
||||
'image': 'busybox:latest',
|
||||
'volumes': ['/var/data'],
|
||||
},
|
||||
'db': {
|
||||
'image': 'busybox:latest',
|
||||
'volumes_from': ['data'],
|
||||
},
|
||||
}),
|
||||
service_dicts=service_dicts,
|
||||
client=self.client,
|
||||
)
|
||||
db = project.get_service('db')
|
||||
|
|
|
|||
|
|
@ -133,7 +133,6 @@ class EnvTest(unittest.TestCase):
|
|||
{'FILE_DEF': 'F1', 'FILE_DEF_EMPTY': '', 'ENV_DEF': 'E3', 'NO_DEF': ''},
|
||||
)
|
||||
|
||||
|
||||
class ExtendsTest(unittest.TestCase):
|
||||
def test_extends(self):
|
||||
service_dicts = config.load('tests/fixtures/extends/docker-compose.yml')
|
||||
|
|
@ -241,3 +240,13 @@ class ExtendsTest(unittest.TestCase):
|
|||
|
||||
with mock.patch.object(config, 'load_yaml', return_value=other_config):
|
||||
print load_config()
|
||||
|
||||
def test_volume_path(self):
|
||||
dicts = config.load('tests/fixtures/volume-path/docker-compose.yml')
|
||||
|
||||
paths = [
|
||||
'%s:/foo' % os.path.abspath('tests/fixtures/volume-path/common/foo'),
|
||||
'%s:/bar' % os.path.abspath('tests/fixtures/volume-path/bar'),
|
||||
]
|
||||
|
||||
self.assertEqual(set(dicts[0]['volumes']), set(paths))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue