Merge pull request #2051 from dnephin/extend_compose_files
Extend compose files by allowing multiple files
This commit is contained in:
commit
18dbe1b1c0
14 changed files with 391 additions and 191 deletions
|
|
@ -9,6 +9,7 @@ from six import StringIO
|
|||
|
||||
from .. import mock
|
||||
from .testcases import DockerClientTestCase
|
||||
from compose.cli.command import get_project
|
||||
from compose.cli.errors import UserError
|
||||
from compose.cli.main import TopLevelCommand
|
||||
from compose.project import NoSuchService
|
||||
|
|
@ -38,7 +39,7 @@ class CLITestCase(DockerClientTestCase):
|
|||
if hasattr(self, '_project'):
|
||||
return self._project
|
||||
|
||||
return self.command.get_project()
|
||||
return get_project(self.command.base_dir)
|
||||
|
||||
def test_help(self):
|
||||
old_base_dir = self.command.base_dir
|
||||
|
|
@ -72,7 +73,7 @@ class CLITestCase(DockerClientTestCase):
|
|||
def test_ps_alternate_composefile(self, mock_stdout):
|
||||
config_path = os.path.abspath(
|
||||
'tests/fixtures/multiple-composefiles/compose2.yml')
|
||||
self._project = self.command.get_project(config_path)
|
||||
self._project = get_project(self.command.base_dir, [config_path])
|
||||
|
||||
self.command.base_dir = 'tests/fixtures/multiple-composefiles'
|
||||
self.command.dispatch(['-f', 'compose2.yml', 'up', '-d'], None)
|
||||
|
|
@ -584,7 +585,6 @@ class CLITestCase(DockerClientTestCase):
|
|||
self.assertEqual(get_port(3002), "0.0.0.0:49153")
|
||||
|
||||
def test_port_with_scale(self):
|
||||
|
||||
self.command.base_dir = 'tests/fixtures/ports-composefile-scale'
|
||||
self.command.dispatch(['scale', 'simple=2'], None)
|
||||
containers = sorted(
|
||||
|
|
@ -607,7 +607,7 @@ class CLITestCase(DockerClientTestCase):
|
|||
def test_env_file_relative_to_compose_file(self):
|
||||
config_path = os.path.abspath('tests/fixtures/env-file/docker-compose.yml')
|
||||
self.command.dispatch(['-f', config_path, 'up', '-d'], None)
|
||||
self._project = self.command.get_project(config_path)
|
||||
self._project = get_project(self.command.base_dir, [config_path])
|
||||
|
||||
containers = self.project.containers(stopped=True)
|
||||
self.assertEqual(len(containers), 1)
|
||||
|
|
@ -628,6 +628,44 @@ class CLITestCase(DockerClientTestCase):
|
|||
self.assertTrue(components[-2:] == ['home-dir', 'my-volume'],
|
||||
msg="Last two components differ: %s, %s" % (actual_host_path, expected_host_path))
|
||||
|
||||
def test_up_with_default_override_file(self):
|
||||
self.command.base_dir = 'tests/fixtures/override-files'
|
||||
self.command.dispatch(['up', '-d'], None)
|
||||
|
||||
containers = self.project.containers()
|
||||
self.assertEqual(len(containers), 2)
|
||||
|
||||
web, db = containers
|
||||
self.assertEqual(web.human_readable_command, 'top')
|
||||
self.assertEqual(db.human_readable_command, 'top')
|
||||
|
||||
def test_up_with_multiple_files(self):
|
||||
self.command.base_dir = 'tests/fixtures/override-files'
|
||||
config_paths = [
|
||||
'docker-compose.yml',
|
||||
'docker-compose.override.yml',
|
||||
'extra.yml',
|
||||
|
||||
]
|
||||
self._project = get_project(self.command.base_dir, config_paths)
|
||||
self.command.dispatch(
|
||||
[
|
||||
'-f', config_paths[0],
|
||||
'-f', config_paths[1],
|
||||
'-f', config_paths[2],
|
||||
'up', '-d',
|
||||
],
|
||||
None)
|
||||
|
||||
containers = self.project.containers()
|
||||
self.assertEqual(len(containers), 3)
|
||||
|
||||
web, other, db = containers
|
||||
self.assertEqual(web.human_readable_command, 'top')
|
||||
self.assertTrue({'db', 'other'} <= set(web.links()))
|
||||
self.assertEqual(db.human_readable_command, 'top')
|
||||
self.assertEqual(other.human_readable_command, 'top')
|
||||
|
||||
def test_up_with_extends(self):
|
||||
self.command.base_dir = 'tests/fixtures/extends'
|
||||
self.command.dispatch(['up', '-d'], None)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue