Skip to content

Commit a1e9a82

Browse files
authored
Merge pull request #1012 from mokibit/automate-exit-from-tests
tests/integration: Automate manual `exit-from` tests
2 parents 585d344 + 9e11c6b commit a1e9a82

File tree

3 files changed

+54
-21
lines changed

3 files changed

+54
-21
lines changed

tests/integration/exit-from/README.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

tests/integration/exit-from/docker-compose.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
version: "3"
22
services:
3-
too_long:
4-
image: nopush/podman-compose-test
5-
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 3600; exit 0"]
6-
tmpfs:
7-
- /run
8-
- /tmp
93
sh1:
104
image: nopush/podman-compose-test
115
command: ["dumb-init", "/bin/busybox", "sh", "-c", "sleep 1; exit 1"]
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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(), "exit-from"), "docker-compose.yaml")
13+
14+
15+
class TestComposeExitFrom(unittest.TestCase, RunSubprocessMixin):
16+
def test_exit_code_sh1(self):
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):
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+
])

0 commit comments

Comments
 (0)