mirror of
https://github.com/containers/podman-compose.git
synced 2025-08-09 21:57:44 +02:00
Adding support for conditional dependencies
Signed-off-by: Felix Rubio <felix@kngnt.org>
This commit is contained in:
committed by
Povilas Kanapickas
parent
3ba0396e7a
commit
a67fa0beb5
@ -7,11 +7,11 @@ 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(), "deps"), "docker-compose.yaml")
|
||||
def compose_yaml_path(suffix=""):
|
||||
return os.path.join(os.path.join(test_path(), "deps"), f"docker-compose{suffix}.yaml")
|
||||
|
||||
|
||||
class TestComposeDeps(unittest.TestCase, RunSubprocessMixin):
|
||||
class TestComposeBaseDeps(unittest.TestCase, RunSubprocessMixin):
|
||||
def test_deps(self):
|
||||
try:
|
||||
output, error = self.run_subprocess_assert_returncode([
|
||||
@ -34,3 +34,48 @@ class TestComposeDeps(unittest.TestCase, RunSubprocessMixin):
|
||||
compose_yaml_path(),
|
||||
"down",
|
||||
])
|
||||
|
||||
|
||||
class TestComposeConditionalDeps(unittest.TestCase, RunSubprocessMixin):
|
||||
def test_deps_succeeds(self):
|
||||
suffix = "-conditional-succeeds"
|
||||
try:
|
||||
output, error = self.run_subprocess_assert_returncode([
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(suffix),
|
||||
"run",
|
||||
"--rm",
|
||||
"sleep",
|
||||
"/bin/sh",
|
||||
"-c",
|
||||
"wget -O - http://web:8000/hosts",
|
||||
])
|
||||
self.assertIn(b"HTTP request sent, awaiting response... 200 OK", output)
|
||||
self.assertIn(b"deps_web_1", output)
|
||||
finally:
|
||||
self.run_subprocess_assert_returncode([
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(suffix),
|
||||
"down",
|
||||
])
|
||||
|
||||
def test_deps_fails(self):
|
||||
suffix = "-conditional-fails"
|
||||
try:
|
||||
output, error = self.run_subprocess_assert_returncode([
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(suffix),
|
||||
"ps",
|
||||
])
|
||||
self.assertNotIn(b"HTTP request sent, awaiting response... 200 OK", output)
|
||||
self.assertNotIn(b"deps_web_1", output)
|
||||
finally:
|
||||
self.run_subprocess_assert_returncode([
|
||||
podman_compose_path(),
|
||||
"-f",
|
||||
compose_yaml_path(suffix),
|
||||
"down",
|
||||
])
|
||||
|
Reference in New Issue
Block a user