tests/integration: Add reset tag attribute test

Signed-off-by: Monika Kairaityte <monika@kibit.lt>
This commit is contained in:
Monika Kairaityte 2025-04-29 15:32:46 +03:00
parent 35dc395483
commit 5ab734026c
4 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,5 @@
version: "3"
services:
app:
image: busybox
command: !reset {}

View File

@ -0,0 +1,5 @@
version: "3"
services:
app:
image: busybox
command: ["/bin/busybox", "echo", "Zero"]

View File

@ -0,0 +1,58 @@
# SPDX-License-Identifier: GPL-2.0
import os
import unittest
from tests.integration.test_utils import RunSubprocessMixin
from tests.integration.test_utils import podman_compose_path
from tests.integration.test_utils import test_path
def compose_yaml_path():
return os.path.join(os.path.join(test_path(), "reset_tag_attribute"), "docker-compose.yaml")
class TestComposeResetTagAttribute(unittest.TestCase, RunSubprocessMixin):
# test if the attribute of the service is correctly reset
def test_reset_tag_attribute(self):
reset_file = os.path.join(
os.path.join(test_path(), "reset_tag_attribute"), "docker-compose.reset_attribute.yaml"
)
try:
self.run_subprocess_assert_returncode([
podman_compose_path(),
"-f",
compose_yaml_path(),
"-f",
reset_file,
"up",
])
# the service still exists, but its command attribute was reset in
# docker-compose.reset_tag_attribute.yaml file and is now empty
output, _ = self.run_subprocess_assert_returncode([
podman_compose_path(),
"-f",
compose_yaml_path(),
"-f",
reset_file,
"ps",
])
self.assertIn(b"reset_tag_attribute_app_1", output)
output, _ = self.run_subprocess_assert_returncode([
podman_compose_path(),
"-f",
compose_yaml_path(),
"-f",
reset_file,
"logs",
])
self.assertEqual(output, b"")
finally:
self.run_subprocess_assert_returncode([
podman_compose_path(),
"-f",
compose_yaml_path(),
"down",
])