Debian Codegraph @

tests/integration/exit_from/test_podman_compose_exit_from.py

raw symbols SCIP
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() -> str:
12 return os.path.join(os.path.join(test_path(), "exit_from"), "docker-compose.yaml")
13
14
15 class TestComposeExitFrom(unittest.TestCase, RunSubprocessMixin):
16 def test_exit_code_sh1(self) -> None:
17 try:
18 self.run_subprocess_assert_returncode(
19 [
20 podman_compose_path(),
21 "-f",
22 compose_yaml_path(),
23 "up",
24 "--exit-code-from=sh1",
25 ],
26 1,
27 )
28 finally:
29 self.run_subprocess_assert_returncode([
30 podman_compose_path(),
31 "-f",
32 compose_yaml_path(),
33 "down",
34 ])
35
36 def test_exit_code_sh2(self) -> None:
37 try:
38 self.run_subprocess_assert_returncode(
39 [
40 podman_compose_path(),
41 "-f",
42 compose_yaml_path(),
43 "up",
44 "--exit-code-from=sh2",
45 ],
46 2,
47 )
48 finally:
49 self.run_subprocess_assert_returncode([
50 podman_compose_path(),
51 "-f",
52 compose_yaml_path(),
53 "down",
54 ])
55
56 def test_podman_compose_exit_from(self) -> None:
57 up_cmd = [
58 "coverage",
59 "run",
60 podman_compose_path(),
61 "-f",
62 compose_yaml_path(),
63 "up",
64 ]
65
66 self.run_subprocess_assert_returncode(up_cmd + ["--exit-code-from", "sh1"], 1)
67 self.run_subprocess_assert_returncode(up_cmd + ["--exit-code-from", "sh2"], 2)