tests/integration: Rename dir build_fail_multi

Renamed directory `build_fail_multi` to more appropriate
`commands_fail_exit_code` as more tests were added to other
commands:`push` and `run`. Names of tests were changed accordingly.

Signed-off-by: Monika Kairaityte <monika@kibit.lt>
This commit is contained in:
Monika Kairaityte
2025-07-02 20:43:47 +03:00
parent c1ca9166c6
commit b3fd55047b
5 changed files with 4 additions and 4 deletions

View File

@ -0,0 +1,3 @@
FROM busybox
RUN false

View File

@ -0,0 +1,8 @@
version: "3"
services:
bad:
build:
context: bad
good:
build:
context: good

View File

@ -0,0 +1,3 @@
FROM busybox
#ensure that this build finishes second so that it has a chance to overwrite the return code
RUN sleep 0.5

View File

@ -0,0 +1,76 @@
# 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() -> str:
""" "Returns the path to the compose file used for this test module"""
base_path = os.path.join(test_path(), "commands_fail_exit_code")
return os.path.join(base_path, "docker-compose.yml")
class TestComposeCommandsFailExitCodes(unittest.TestCase, RunSubprocessMixin):
def test_build_command_fail(self) -> None:
output, error = self.run_subprocess_assert_returncode(
[
podman_compose_path(),
"-f",
compose_yaml_path(),
"build",
# prevent the successful build from being cached to ensure it runs long enough
"--no-cache",
],
expected_returncode=1,
)
self.assertIn("RUN false", str(output))
self.assertIn("while running runtime: exit status 1", str(error))
def test_push_command_fail(self) -> None:
# test that push command is able to return other than "0" return code
# "push" command fails due to several steps missing before running it (logging, tagging)
try:
output, error = self.run_subprocess_assert_returncode(
[
podman_compose_path(),
"-f",
compose_yaml_path(),
"push",
"good",
],
expected_returncode=125,
)
finally:
self.run_subprocess_assert_returncode([
podman_compose_path(),
"-f",
compose_yaml_path(),
"down",
])
def test_run_command_fail(self) -> None:
# test that run command is able to return other than "0" return code
try:
output, error = self.run_subprocess_assert_returncode(
[
podman_compose_path(),
"-f",
compose_yaml_path(),
"run",
"bad",
],
expected_returncode=125,
)
self.assertIn("RUN false", str(output))
self.assertIn("while running runtime: exit status 1", str(error))
finally:
self.run_subprocess_assert_returncode([
podman_compose_path(),
"-f",
compose_yaml_path(),
"down",
])