-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Otto Liljalaakso <[email protected]>
- Loading branch information
1 parent
6103df7
commit 2e1cef8
Showing
7 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Test podman-compose with build.additional_contexts | ||
|
||
``` | ||
podman-compose build | ||
podman-compose up | ||
podman-compose down | ||
``` | ||
|
||
expected output would be | ||
|
||
``` | ||
[dict] | Data for dict | ||
[list] | Data for list | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Data for dict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Data for list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM busybox | ||
COPY --from=data data.txt /data/data.txt | ||
CMD ["busybox", "cat", "/data/data.txt"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: "3.7" | ||
services: | ||
dict: | ||
build: | ||
context: . | ||
additional_contexts: | ||
data: ../data_for_dict | ||
list: | ||
build: | ||
context: . | ||
additional_contexts: | ||
- data=../data_for_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
|
||
"""Test how additional contexts are passed to podman.""" | ||
|
||
import os | ||
import subprocess | ||
import unittest | ||
|
||
from .test_podman_compose import podman_compose_path | ||
from .test_podman_compose import test_path | ||
|
||
|
||
def compose_yaml_path(): | ||
""" "Returns the path to the compose file used for this test module""" | ||
return os.path.join(test_path(), "additional_contexts", "project") | ||
|
||
|
||
class TestComposeBuildAdditionalContexts(unittest.TestCase): | ||
def test_build_additional_context(self): | ||
"""podman build should receive additional contexts as --build-context | ||
See additional_context/project/docker-compose.yaml for context paths | ||
""" | ||
cmd = ( | ||
"coverage", | ||
"run", | ||
podman_compose_path(), | ||
"--dry-run", | ||
"--verbose", | ||
"-f", | ||
os.path.join(compose_yaml_path(), "docker-compose.yml"), | ||
"build", | ||
) | ||
p = subprocess.run( | ||
cmd, | ||
stdout=subprocess.PIPE, | ||
check=False, | ||
stderr=subprocess.STDOUT, | ||
text=True, | ||
) | ||
self.assertEqual(p.returncode, 0) | ||
self.assertIn("--build-context=data=../data_for_dict", p.stdout) | ||
self.assertIn("--build-context=data=../data_for_list", p.stdout) |