| 1 |
|
| 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 bad_compose_yaml_path() -> str: |
| 12 |
base_path = os.path.join(test_path(), "parse-error") |
| 13 |
return os.path.join(base_path, "docker-compose-error.yml") |
| 14 |
|
| 15 |
|
| 16 |
def good_compose_yaml_path() -> str: |
| 17 |
base_path = os.path.join(test_path(), "parse-error") |
| 18 |
return os.path.join(base_path, "docker-compose.yml") |
| 19 |
|
| 20 |
|
| 21 |
class TestComposeBuildParseError(unittest.TestCase, RunSubprocessMixin): |
| 22 |
def test_no_error(self) -> None: |
| 23 |
_, err = self.run_subprocess_assert_returncode( |
| 24 |
[podman_compose_path(), "-f", good_compose_yaml_path(), "config"], 0 |
| 25 |
) |
| 26 |
self.assertEqual(b"", err) |
| 27 |
|
| 28 |
def test_simple_parse_error(self) -> None: |
| 29 |
_, err = self.run_subprocess_assert_returncode( |
| 30 |
[podman_compose_path(), "-f", bad_compose_yaml_path(), "config"], 1 |
| 31 |
) |
| 32 |
self.assertIn(b"could not find expected ':'", err) |
| 33 |
self.assertNotIn(b"\nTraceback (most recent call last):\n", err) |
| 34 |
|
| 35 |
def test_verbose_parse_error_contains_stack_trace(self) -> None: |
| 36 |
_, err = self.run_subprocess_assert_returncode( |
| 37 |
[podman_compose_path(), "--verbose", "-f", bad_compose_yaml_path(), "config"], 1 |
| 38 |
) |
| 39 |
self.assertIn(b"\nTraceback (most recent call last):\n", err) |