Skip to content

Commit efc7f2a

Browse files
committed
tests/integration: Add reset tag attribute test
Signed-off-by: Monika Kairaityte <[email protected]>
1 parent e9b5d0d commit efc7f2a

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version: "3"
2+
services:
3+
app:
4+
image: busybox
5+
command: !reset {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version: "3"
2+
services:
3+
app:
4+
image: busybox
5+
command: ["/bin/busybox", "echo", "Zero"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
3+
import os
4+
import unittest
5+
6+
from tests.integration.test_utils import RunSubprocessMixin
7+
from tests.integration.test_utils import podman_compose_path
8+
from tests.integration.test_utils import test_path
9+
10+
11+
def compose_yaml_path():
12+
return os.path.join(os.path.join(test_path(), "reset_tag_attribute"), "docker-compose.yaml")
13+
14+
15+
class TestComposeResetTagAttribute(unittest.TestCase, RunSubprocessMixin):
16+
# test if the attribute of the service is correctly reset
17+
def test_reset_tag_attribute(self):
18+
reset_file = os.path.join(
19+
os.path.join(test_path(), "reset_tag_attribute"), "docker-compose.reset_attribute.yaml"
20+
)
21+
try:
22+
self.run_subprocess_assert_returncode([
23+
podman_compose_path(),
24+
"-f",
25+
compose_yaml_path(),
26+
"-f",
27+
reset_file,
28+
"up",
29+
])
30+
31+
# the service still exists, but its command attribute was reset in
32+
# docker-compose.reset_tag_attribute.yaml file and is now empty
33+
output, _ = self.run_subprocess_assert_returncode([
34+
podman_compose_path(),
35+
"-f",
36+
compose_yaml_path(),
37+
"-f",
38+
reset_file,
39+
"ps",
40+
])
41+
self.assertIn(b"reset_tag_attribute_app_1", output)
42+
43+
output, _ = self.run_subprocess_assert_returncode([
44+
podman_compose_path(),
45+
"-f",
46+
compose_yaml_path(),
47+
"-f",
48+
reset_file,
49+
"logs",
50+
])
51+
self.assertEqual(output, b"")
52+
finally:
53+
self.run_subprocess_assert_returncode([
54+
podman_compose_path(),
55+
"-f",
56+
compose_yaml_path(),
57+
"down",
58+
])

0 commit comments

Comments
 (0)