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:
Aanand Prasad 2015-03-18 18:23:17 -07:00
commit 37efdb1f8b
5 changed files with 80 additions and 12 deletions

View file

@ -0,0 +1,5 @@
db:
image: busybox
volumes:
- ./foo:/foo
- ./bar:/bar

View file

@ -0,0 +1,6 @@
db:
extends:
file: common/services.yml
service: db
volumes:
- ./bar:/bar

View file

@ -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')

View file

@ -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))