Debian Codegraph @

tests/integration/build_fail/test_podman_compose_build_fail.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():
12 """Returns the path to the compose file used for this test module"""
13 base_path = os.path.join(test_path(), "build_fail")
14 return os.path.join(base_path, "docker-compose.yml")
15
16
17 class TestComposeBuildFail(unittest.TestCase, RunSubprocessMixin):
18 def test_build_fail(self):
19 output, error = self.run_subprocess_assert_returncode(
20 [
21 podman_compose_path(),
22 "-f",
23 compose_yaml_path(),
24 "build",
25 "test",
26 ],
27 expected_returncode=127,
28 )
29 self.assertIn("RUN this_command_does_not_exist", str(output))
30 self.assertIn("this_command_does_not_exist: not found", str(error))
31 self.assertIn("while running runtime: exit status 127", str(error))
32
33 def test_dockerfile_does_not_exist(self):
34 out, error = self.run_subprocess_assert_returncode(
35 [
36 podman_compose_path(),
37 "-f",
38 compose_yaml_path(),
39 "build",
40 "test_no_dockerfile",
41 ],
42 expected_returncode=1,
43 )
44 error = error.decode('utf-8')
45 result = '\n'.join(error.splitlines()[-1:])
46
47 expected_path = os.path.join(os.path.dirname(__file__), "context_no_file")
48 expected = f'OSError: Dockerfile not found in {expected_path}'
49
50 self.assertEqual(expected, result)
51
52 def test_custom_dockerfile_does_not_exist(self):
53 out, error = self.run_subprocess_assert_returncode(
54 [
55 podman_compose_path(),
56 "-f",
57 compose_yaml_path(),
58 "build",
59 "test_no_custom_dockerfile",
60 ],
61 expected_returncode=1,
62 )
63 error = error.decode('utf-8')
64 result = '\n'.join(error.splitlines()[-1:])
65
66 expected_path = os.path.join(os.path.dirname(__file__), "context_no_file/Dockerfile-alt")
67 expected = f'OSError: Dockerfile not found in {expected_path}'
68
69 self.assertEqual(expected, result)