Skip to content

fix(core): wait in test core registry #812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions core/tests/test_core_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from testcontainers.core.config import testcontainers_config
from testcontainers.core.container import DockerContainer
from testcontainers.core.docker_client import DockerClient
from testcontainers.core.waiting_utils import wait_container_is_ready
from testcontainers.core.waiting_utils import wait_for_logs

from testcontainers.registry import DockerRegistryContainer

Expand All @@ -38,18 +38,18 @@ def test_missing_on_private_registry(monkeypatch):
with pytest.raises(NotFound):
# Test a container with image from private registry
with DockerContainer(f"{registry_url}/{image}:{tag}") as test_container:
wait_container_is_ready(test_container)
wait_for_logs(test_container, "Hello from Docker!")


@pytest.mark.parametrize(
"image,tag,username,password",
"image,tag,username,password,expected_output",
[
("nginx", "test", "user", "pass"),
("hello-world", "latest", "new_user", "new_pass"),
("alpine", "3.12", None, None),
("nginx", "test", "user", "pass", "start worker processes"),
("hello-world", "latest", "new_user", "new_pass", "Hello from Docker!"),
("alpine", "3.12", None, None, ""),
],
)
def test_with_private_registry(image, tag, username, password, monkeypatch):
def test_with_private_registry(image, tag, username, password, expected_output, monkeypatch):
client = DockerClient().client

with DockerRegistryContainer(username=username, password=password) as registry:
Expand All @@ -76,7 +76,7 @@ def test_with_private_registry(image, tag, username, password, monkeypatch):

# Test a container with image from private registry
with DockerContainer(f"{registry_url}/{image}:{tag}") as test_container:
wait_container_is_ready(test_container)
wait_for_logs(test_container, expected_output)

# cleanup
client.images.remove(f"{registry_url}/{image}:{tag}")
Expand Down