File: test_podman_compose_abort.py

package info (click to toggle)
podman-compose 1.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,996 kB
  • sloc: python: 10,946; sh: 107; javascript: 48; makefile: 13
file content (46 lines) | stat: -rw-r--r-- 1,458 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# SPDX-License-Identifier: GPL-2.0

import os
import unittest

from parameterized import parameterized

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(failure_order: str) -> str:
    return os.path.join(test_path(), "abort", f"docker-compose-fail-{failure_order}.yaml")


class TestComposeAbort(unittest.TestCase, RunSubprocessMixin):
    @parameterized.expand([
        ("exit", "first", 0),
        ("failure", "first", 1),
        ("exit", "second", 0),
        ("failure", "second", 1),
        ("exit", "simultaneous", 0),
        ("failure", "simultaneous", 1),
        ("exit", "none", 0),
        ("failure", "none", 0),
    ])
    def test_abort(self, abort_type: str, failure_order: str, expected_exit_code: int) -> None:
        try:
            self.run_subprocess_assert_returncode(
                [
                    podman_compose_path(),
                    "-f",
                    compose_yaml_path(failure_order),
                    "up",
                    f"--abort-on-container-{abort_type}",
                ],
                expected_exit_code,
            )
        finally:
            self.run_subprocess_assert_returncode([
                podman_compose_path(),
                "-f",
                compose_yaml_path(failure_order),
                "down",
            ])