Merge pull request #6826 from ulyssessouza/env_override_integration_test
Add integration tests regarding environment
Jean-Christophe Sirot authored 4 years ago
GitHub committed 4 years ago
63 | 63 | return ProcessResult(stdout.decode('utf-8'), stderr.decode('utf-8')) |
64 | 64 | |
65 | 65 | |
66 | def dispatch(base_dir, options, project_options=None, returncode=0): | |
67 | project_options = project_options or [] | |
68 | proc = start_process(base_dir, project_options + options) | |
69 | return wait_on_process(proc, returncode=returncode) | |
70 | ||
71 | ||
66 | 72 | def wait_on_condition(condition, delay=0.1, timeout=40): |
67 | 73 | start_time = time.time() |
68 | 74 | while not condition(): |
150 | 156 | return self._project |
151 | 157 | |
152 | 158 | def dispatch(self, options, project_options=None, returncode=0): |
153 | project_options = project_options or [] | |
154 | proc = start_process(self.base_dir, project_options + options) | |
155 | return wait_on_process(proc, returncode=returncode) | |
159 | return dispatch(self.base_dir, options, project_options, returncode) | |
156 | 160 | |
157 | 161 | def execute(self, container, cmd): |
158 | 162 | # Remove once Hijack and CloseNotifier sign a peace treaty |
0 | WHEREAMI=override |
6 | 6 | from ddt import ddt |
7 | 7 | |
8 | 8 | from .. import mock |
9 | from ..acceptance.cli_test import dispatch | |
10 | from compose.cli.command import get_project | |
9 | 11 | from compose.cli.command import project_from_options |
12 | from compose.config.environment import Environment | |
10 | 13 | from tests.integration.testcases import DockerClientTestCase |
11 | 14 | |
12 | 15 | |
49 | 52 | # So no need to have a proper options map, the `COMMAND` key is enough |
50 | 53 | project_from_options('.', options) |
51 | 54 | assert fake_log.warn.call_count == 0 |
55 | ||
56 | ||
57 | class EnvironmentOverrideFileTest(DockerClientTestCase): | |
58 | def test_env_file_override(self): | |
59 | base_dir = 'tests/fixtures/env-file-override' | |
60 | dispatch(base_dir, ['--env-file', '.env.override', 'up']) | |
61 | project = get_project(project_dir=base_dir, | |
62 | config_path=['docker-compose.yml'], | |
63 | environment=Environment.from_env_file(base_dir, '.env.override'), | |
64 | override_dir=base_dir) | |
65 | containers = project.containers(stopped=True) | |
66 | assert len(containers) == 1 | |
67 | assert "WHEREAMI=override" in containers[0].get('Config.Env') | |
68 | assert "DEFAULT_CONF_LOADED=true" in containers[0].get('Config.Env') | |
69 | dispatch(base_dir, ['--env-file', '.env.override', 'down'], None) |