mirror of
https://github.com/containers/podman-compose.git
synced 2025-05-28 14:17:50 +02:00
test/integration: Test COMPOSE_PROJECT_NAME interpolation
Refs #1073 Signed-off-by: Ruben Jenster <r.jenster@drachenfels.de>
This commit is contained in:
parent
52e2912e0b
commit
170411de8b
@ -1,5 +1,7 @@
|
||||
version: "3"
|
||||
|
||||
name: my-project-name
|
||||
|
||||
services:
|
||||
env-test:
|
||||
image: busybox
|
||||
@ -8,3 +10,9 @@ services:
|
||||
ZZVAR1: myval1
|
||||
ZZVAR2: 2-$ZZVAR1
|
||||
ZZVAR3: 3-$ZZVAR2
|
||||
|
||||
project-name-test:
|
||||
image: busybox
|
||||
command: sh -c "echo $$PNAME"
|
||||
environment:
|
||||
PNAME: ${COMPOSE_PROJECT_NAME}
|
||||
|
@ -36,3 +36,34 @@ class TestComposeEnv(unittest.TestCase, RunSubprocessMixin):
|
||||
compose_yaml_path(),
|
||||
"down",
|
||||
])
|
||||
|
||||
"""
|
||||
Tests interpolation of COMPOSE_PROJECT_NAME in the podman-compose config,
|
||||
which is different from external environment variables because COMPOSE_PROJECT_NAME
|
||||
is a predefined environment variable generated from the `name` value in the top-level
|
||||
of the compose.yaml.
|
||||
|
||||
See also
|
||||
- https://docs.docker.com/reference/compose-file/interpolation/
|
||||
- https://docs.docker.com/reference/compose-file/version-and-name/#name-top-level-element
|
||||
- https://docs.docker.com/compose/how-tos/environment-variables/envvars/
|
||||
- https://github.com/compose-spec/compose-spec/blob/main/04-version-and-name.md
|
||||
"""
|
||||
|
||||
def test_project_name(self):
|
||||
try:
|
||||
output, _ = self.run_subprocess_assert_returncode([
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(),
|
||||
"run",
|
||||
"project-name-test",
|
||||
])
|
||||
self.assertIn("my-project-name", str(output))
|
||||
finally:
|
||||
self.run_subprocess_assert_returncode([
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(),
|
||||
"down",
|
||||
])
|
||||
|
Loading…
x
Reference in New Issue
Block a user