Skip to content

Commit edadf73

Browse files
authored
Merge pull request #1017 from mokibit/automate-extends-tests
tests/integration: Automate manual 'extends' test
2 parents 348461c + dc04108 commit edadf73

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
3+
import os
4+
import unittest
5+
6+
from tests.integration.test_podman_compose import podman_compose_path
7+
from tests.integration.test_podman_compose import test_path
8+
from tests.integration.test_utils import RunSubprocessMixin
9+
10+
11+
def compose_yaml_path():
12+
return os.path.join(os.path.join(test_path(), "extends"), "docker-compose.yaml")
13+
14+
15+
class TestComposeExteds(unittest.TestCase, RunSubprocessMixin):
16+
def test_extends_service_launch_echo(self):
17+
try:
18+
self.run_subprocess_assert_returncode([
19+
podman_compose_path(),
20+
"-f",
21+
compose_yaml_path(),
22+
"up",
23+
"echo",
24+
])
25+
output, _ = self.run_subprocess_assert_returncode([
26+
podman_compose_path(),
27+
"-f",
28+
compose_yaml_path(),
29+
"logs",
30+
"echo",
31+
])
32+
self.assertEqual(output, b"Zero\n")
33+
finally:
34+
self.run_subprocess_assert_returncode([
35+
podman_compose_path(),
36+
"-f",
37+
compose_yaml_path(),
38+
"down",
39+
])
40+
41+
def test_extends_service_launch_echo1(self):
42+
try:
43+
self.run_subprocess_assert_returncode([
44+
podman_compose_path(),
45+
"-f",
46+
compose_yaml_path(),
47+
"up",
48+
"echo1",
49+
])
50+
output, _ = self.run_subprocess_assert_returncode([
51+
podman_compose_path(),
52+
"-f",
53+
compose_yaml_path(),
54+
"logs",
55+
"echo1",
56+
])
57+
self.assertEqual(output, b"One\n")
58+
finally:
59+
self.run_subprocess_assert_returncode([
60+
podman_compose_path(),
61+
"-f",
62+
compose_yaml_path(),
63+
"down",
64+
])
65+
66+
def test_extends_service_launch_env1(self):
67+
try:
68+
self.run_subprocess_assert_returncode([
69+
podman_compose_path(),
70+
"-f",
71+
compose_yaml_path(),
72+
"up",
73+
"env1",
74+
])
75+
output, _ = self.run_subprocess_assert_returncode([
76+
podman_compose_path(),
77+
"-f",
78+
compose_yaml_path(),
79+
"logs",
80+
"env1",
81+
])
82+
lines = output.decode('utf-8').split('\n')
83+
# HOSTNAME name is random string so is ignored in asserting
84+
lines = sorted([line for line in lines if not line.startswith("HOSTNAME")])
85+
self.assertEqual(
86+
lines,
87+
[
88+
'',
89+
'BAR=local',
90+
'BAZ=local',
91+
'FOO=original',
92+
'HOME=/root',
93+
'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
94+
'TERM=xterm',
95+
'container=podman',
96+
],
97+
)
98+
finally:
99+
self.run_subprocess_assert_returncode([
100+
podman_compose_path(),
101+
"-f",
102+
compose_yaml_path(),
103+
"down",
104+
])

0 commit comments

Comments
 (0)