Skip to content

Commit 96e7a14

Browse files
test(compose): improve compose tests when running specific services
1 parent f61dcda commit 96e7a14

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

compose/tests/test_docker_compose.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_can_build_images_before_spawning_service_via_compose():
3939
assert "--build" in docker_compose_cmd
4040

4141

42-
def test_can_run_specific_services():
42+
def test_can_specify_services():
4343
with patch.object(DockerCompose, "_call_command") as call_mock:
4444
with DockerCompose(ROOT, services=["hub", "firefox"]) as compose:
4545
...
@@ -52,6 +52,25 @@ def test_can_run_specific_services():
5252
assert "chrome" not in docker_compose_cmd
5353

5454

55+
@pytest.mark.parametrize("should_run_hub", [
56+
[True],
57+
[False],
58+
])
59+
def test_can_run_specific_services(should_run_hub: bool):
60+
# compose V2 will improve this test by being able to assert that "firefox" also has started and exited
61+
services = ["firefox"]
62+
if should_run_hub:
63+
services.append("hub")
64+
65+
with DockerCompose(ROOT, services=services) as compose:
66+
if should_run_hub:
67+
assert compose.get_service_host("hub", 4444)
68+
assert compose.get_service_port("hub", 4444)
69+
else:
70+
with pytest.raises(NoSuchPortExposed):
71+
assert compose.get_service_host("hub", 4444)
72+
73+
5574
def test_can_throw_exception_if_no_port_exposed():
5675
with DockerCompose(ROOT) as compose:
5776
with pytest.raises(NoSuchPortExposed):

0 commit comments

Comments
 (0)