mirror of
https://github.com/containers/podman-compose.git
synced 2025-02-05 12:59:40 +01:00
tests/integration: Move test "extends_w_file_subdir" to corresp. dir
Signed-off-by: Monika Kairaityte <monika@kibit.lt>
This commit is contained in:
parent
c2d3e156c2
commit
24bdfd1e17
1
tests/integration/extends_w_file_subdir/__init__.py
Normal file
1
tests/integration/extends_w_file_subdir/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1,104 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from tests.integration.test_podman_compose import podman_compose_path
|
||||
from tests.integration.test_podman_compose import test_path
|
||||
from tests.integration.test_utils import RunSubprocessMixin
|
||||
|
||||
|
||||
def compose_yaml_path():
|
||||
return os.path.join(os.path.join(test_path(), "extends_w_file_subdir"), "docker-compose.yml")
|
||||
|
||||
|
||||
class TestComposeExtendsWithFileSubdir(unittest.TestCase, RunSubprocessMixin):
|
||||
def test_extends_w_file_subdir(self): # when file is Dockerfile for building the image
|
||||
try:
|
||||
self.run_subprocess_assert_returncode(
|
||||
[
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(),
|
||||
"up",
|
||||
],
|
||||
)
|
||||
output, _ = self.run_subprocess_assert_returncode([
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(),
|
||||
"ps",
|
||||
])
|
||||
self.assertIn("extends_w_file_subdir_web_1", str(output))
|
||||
finally:
|
||||
self.run_subprocess_assert_returncode([
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(),
|
||||
"down",
|
||||
])
|
||||
|
||||
def test_podman_compose_extends_w_file_subdir(self):
|
||||
"""
|
||||
Test that podman-compose can execute podman-compose -f <file> up with extended File which
|
||||
includes a build context
|
||||
:return:
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent.parent
|
||||
|
||||
command_up = [
|
||||
"coverage",
|
||||
"run",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "extends_w_file_subdir", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
command_check_container = [
|
||||
"coverage",
|
||||
"run",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "extends_w_file_subdir", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"ps",
|
||||
"--format",
|
||||
'{{.Image}}',
|
||||
]
|
||||
|
||||
self.run_subprocess_assert_returncode(command_up)
|
||||
# check container was created and exists
|
||||
out, _ = self.run_subprocess_assert_returncode(command_check_container)
|
||||
self.assertEqual(out, b'localhost/subdir_test:me\n')
|
||||
# cleanup test image(tags)
|
||||
self.run_subprocess_assert_returncode([
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "extends_w_file_subdir", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"down",
|
||||
])
|
||||
|
||||
self.run_subprocess_assert_returncode([
|
||||
"podman",
|
||||
"rmi",
|
||||
"--force",
|
||||
"localhost/subdir_test:me",
|
||||
])
|
||||
|
||||
# check container did not exists anymore
|
||||
out, _ = self.run_subprocess_assert_returncode(command_check_container)
|
||||
self.assertEqual(out, b'')
|
@ -4,8 +4,6 @@ import os
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from tests.integration.test_utils import RunSubprocessMixin
|
||||
|
||||
|
||||
def base_path():
|
||||
"""Returns the base path for the project"""
|
||||
@ -20,69 +18,3 @@ def test_path():
|
||||
def podman_compose_path():
|
||||
"""Returns the path to the podman compose script"""
|
||||
return os.path.join(base_path(), "podman_compose.py")
|
||||
|
||||
|
||||
class TestPodmanCompose(unittest.TestCase, RunSubprocessMixin):
|
||||
def test_extends_w_file_subdir(self):
|
||||
"""
|
||||
Test that podman-compose can execute podman-compose -f <file> up with extended File which
|
||||
includes a build context
|
||||
:return:
|
||||
"""
|
||||
main_path = Path(__file__).parent.parent.parent
|
||||
|
||||
command_up = [
|
||||
"coverage",
|
||||
"run",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "extends_w_file_subdir", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"up",
|
||||
"-d",
|
||||
]
|
||||
|
||||
command_check_container = [
|
||||
"coverage",
|
||||
"run",
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "extends_w_file_subdir", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"ps",
|
||||
"--format",
|
||||
'{{.Image}}',
|
||||
]
|
||||
|
||||
self.run_subprocess_assert_returncode(command_up)
|
||||
# check container was created and exists
|
||||
out, _ = self.run_subprocess_assert_returncode(command_check_container)
|
||||
self.assertEqual(out, b'localhost/subdir_test:me\n')
|
||||
# cleanup test image(tags)
|
||||
self.run_subprocess_assert_returncode([
|
||||
str(main_path.joinpath("podman_compose.py")),
|
||||
"-f",
|
||||
str(
|
||||
main_path.joinpath(
|
||||
"tests", "integration", "extends_w_file_subdir", "docker-compose.yml"
|
||||
)
|
||||
),
|
||||
"down",
|
||||
])
|
||||
|
||||
self.run_subprocess_assert_returncode([
|
||||
"podman",
|
||||
"rmi",
|
||||
"--force",
|
||||
"localhost/subdir_test:me",
|
||||
])
|
||||
|
||||
# check container did not exists anymore
|
||||
out, _ = self.run_subprocess_assert_returncode(command_check_container)
|
||||
self.assertEqual(out, b'')
|
||||
|
@ -1,39 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from tests.integration.test_podman_compose import podman_compose_path
|
||||
from tests.integration.test_podman_compose import test_path
|
||||
from tests.integration.test_utils import RunSubprocessMixin
|
||||
|
||||
|
||||
def compose_yaml_path():
|
||||
return os.path.join(os.path.join(test_path(), "extends_w_file_subdir"), "docker-compose.yml")
|
||||
|
||||
|
||||
class TestComposeExtendsWithFileSubdir(unittest.TestCase, RunSubprocessMixin):
|
||||
def test_extends_w_file_subdir(self): # when file is Dockerfile for building the image
|
||||
try:
|
||||
self.run_subprocess_assert_returncode(
|
||||
[
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(),
|
||||
"up",
|
||||
],
|
||||
)
|
||||
output, _ = self.run_subprocess_assert_returncode([
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(),
|
||||
"ps",
|
||||
])
|
||||
self.assertIn("extends_w_file_subdir_web_1", str(output))
|
||||
finally:
|
||||
self.run_subprocess_assert_returncode([
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(),
|
||||
"down",
|
||||
])
|
Loading…
Reference in New Issue
Block a user