mirror of https://github.com/docker/compose.git
Merge pull request #6826 from ulyssessouza/env_override_integration_test
Add integration tests regarding environment
This commit is contained in:
commit
cf3c07d6ee
|
@ -64,6 +64,12 @@ def wait_on_process(proc, returncode=0):
|
||||||
return ProcessResult(stdout.decode('utf-8'), stderr.decode('utf-8'))
|
return ProcessResult(stdout.decode('utf-8'), stderr.decode('utf-8'))
|
||||||
|
|
||||||
|
|
||||||
|
def dispatch(base_dir, options, project_options=None, returncode=0):
|
||||||
|
project_options = project_options or []
|
||||||
|
proc = start_process(base_dir, project_options + options)
|
||||||
|
return wait_on_process(proc, returncode=returncode)
|
||||||
|
|
||||||
|
|
||||||
def wait_on_condition(condition, delay=0.1, timeout=40):
|
def wait_on_condition(condition, delay=0.1, timeout=40):
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
while not condition():
|
while not condition():
|
||||||
|
@ -151,9 +157,7 @@ class CLITestCase(DockerClientTestCase):
|
||||||
return self._project
|
return self._project
|
||||||
|
|
||||||
def dispatch(self, options, project_options=None, returncode=0):
|
def dispatch(self, options, project_options=None, returncode=0):
|
||||||
project_options = project_options or []
|
return dispatch(self.base_dir, options, project_options, returncode)
|
||||||
proc = start_process(self.base_dir, project_options + options)
|
|
||||||
return wait_on_process(proc, returncode=returncode)
|
|
||||||
|
|
||||||
def execute(self, container, cmd):
|
def execute(self, container, cmd):
|
||||||
# Remove once Hijack and CloseNotifier sign a peace treaty
|
# Remove once Hijack and CloseNotifier sign a peace treaty
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
WHEREAMI
|
||||||
|
DEFAULT_CONF_LOADED=true
|
|
@ -0,0 +1 @@
|
||||||
|
WHEREAMI=override
|
|
@ -0,0 +1,6 @@
|
||||||
|
version: '3.7'
|
||||||
|
services:
|
||||||
|
test:
|
||||||
|
image: busybox
|
||||||
|
env_file: .env.conf
|
||||||
|
entrypoint: env
|
|
@ -7,7 +7,10 @@ from ddt import data
|
||||||
from ddt import ddt
|
from ddt import ddt
|
||||||
|
|
||||||
from .. import mock
|
from .. import mock
|
||||||
|
from ..acceptance.cli_test import dispatch
|
||||||
|
from compose.cli.command import get_project
|
||||||
from compose.cli.command import project_from_options
|
from compose.cli.command import project_from_options
|
||||||
|
from compose.config.environment import Environment
|
||||||
from tests.integration.testcases import DockerClientTestCase
|
from tests.integration.testcases import DockerClientTestCase
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,3 +53,18 @@ services:
|
||||||
# So no need to have a proper options map, the `COMMAND` key is enough
|
# So no need to have a proper options map, the `COMMAND` key is enough
|
||||||
project_from_options('.', options)
|
project_from_options('.', options)
|
||||||
assert fake_log.warn.call_count == 0
|
assert fake_log.warn.call_count == 0
|
||||||
|
|
||||||
|
|
||||||
|
class EnvironmentOverrideFileTest(DockerClientTestCase):
|
||||||
|
def test_env_file_override(self):
|
||||||
|
base_dir = 'tests/fixtures/env-file-override'
|
||||||
|
dispatch(base_dir, ['--env-file', '.env.override', 'up'])
|
||||||
|
project = get_project(project_dir=base_dir,
|
||||||
|
config_path=['docker-compose.yml'],
|
||||||
|
environment=Environment.from_env_file(base_dir, '.env.override'),
|
||||||
|
override_dir=base_dir)
|
||||||
|
containers = project.containers(stopped=True)
|
||||||
|
assert len(containers) == 1
|
||||||
|
assert "WHEREAMI=override" in containers[0].get('Config.Env')
|
||||||
|
assert "DEFAULT_CONF_LOADED=true" in containers[0].get('Config.Env')
|
||||||
|
dispatch(base_dir, ['--env-file', '.env.override', 'down'], None)
|
||||||
|
|
Loading…
Reference in New Issue