| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
"""Test how additional contexts are passed to podman.""" |
| 5 |
|
| 6 |
import os |
| 7 |
import subprocess |
| 8 |
import unittest |
| 9 |
|
| 10 |
from tests.integration.test_utils import podman_compose_path |
| 11 |
from tests.integration.test_utils import test_path |
| 12 |
|
| 13 |
|
| 14 |
def compose_yaml_path() -> str: |
| 15 |
""" "Returns the path to the compose file used for this test module""" |
| 16 |
return os.path.join(test_path(), "additional_contexts", "project") |
| 17 |
|
| 18 |
|
| 19 |
class TestComposeBuildAdditionalContexts(unittest.TestCase): |
| 20 |
def test_build_additional_context(self) -> None: |
| 21 |
"""podman build should receive additional contexts as --build-context |
| 22 |
|
| 23 |
See additional_context/project/docker-compose.yaml for context paths |
| 24 |
""" |
| 25 |
cmd = ( |
| 26 |
"coverage", |
| 27 |
"run", |
| 28 |
podman_compose_path(), |
| 29 |
"--dry-run", |
| 30 |
"--verbose", |
| 31 |
"-f", |
| 32 |
os.path.join(compose_yaml_path(), "docker-compose.yml"), |
| 33 |
"build", |
| 34 |
) |
| 35 |
p = subprocess.run( |
| 36 |
cmd, |
| 37 |
stdout=subprocess.PIPE, |
| 38 |
check=False, |
| 39 |
stderr=subprocess.STDOUT, |
| 40 |
text=True, |
| 41 |
) |
| 42 |
self.assertEqual(p.returncode, 0) |
| 43 |
self.assertIn("--build-context=data=../data_for_dict", p.stdout) |
| 44 |
self.assertIn("--build-context=data=../data_for_list", p.stdout) |