File tree 2 files changed +38
-0
lines changed
tests/integration/env-tests
2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 1
1
version : " 3"
2
2
3
+ name : my-project-name
4
+
3
5
services :
4
6
env-test :
5
7
image : busybox
@@ -8,3 +10,9 @@ services:
8
10
ZZVAR1 : myval1
9
11
ZZVAR2 : 2-$ZZVAR1
10
12
ZZVAR3 : 3-$ZZVAR2
13
+
14
+ project-name-test :
15
+ image : busybox
16
+ command : sh -c "echo $$PNAME"
17
+ environment :
18
+ PNAME : ${COMPOSE_PROJECT_NAME}
Original file line number Diff line number Diff line change @@ -36,3 +36,33 @@ def test_env(self):
36
36
compose_yaml_path (),
37
37
"down" ,
38
38
])
39
+
40
+ """
41
+ Tests interpolation of COMPOSE_PROJECT_NAME in the podman-compose config,
42
+ which is different from external environment variables because COMPOSE_PROJECT_NAME
43
+ is a predefined environment variable generated from the `name` value in the top-level
44
+ of the compose.yaml.
45
+
46
+ See also
47
+ - https://docs.docker.com/reference/compose-file/interpolation/
48
+ - https://docs.docker.com/reference/compose-file/version-and-name/#name-top-level-element
49
+ - https://docs.docker.com/compose/how-tos/environment-variables/envvars/
50
+ - https://github.com/compose-spec/compose-spec/blob/main/04-version-and-name.md
51
+ """
52
+ def test_project_name (self ):
53
+ try :
54
+ output , _ = self .run_subprocess_assert_returncode ([
55
+ podman_compose_path (),
56
+ "-f" ,
57
+ compose_yaml_path (),
58
+ "run" ,
59
+ "project-name-test" ,
60
+ ])
61
+ self .assertIn ("my-project-name" , str (output ))
62
+ finally :
63
+ self .run_subprocess_assert_returncode ([
64
+ podman_compose_path (),
65
+ "-f" ,
66
+ compose_yaml_path (),
67
+ "down" ,
68
+ ])
You can’t perform that action at this time.
0 commit comments