Skip to content

Commit a9d5bc9

Browse files
committed
test(redis): Add test for wait strategy
1 parent c7bcc89 commit a9d5bc9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

modules/redis/tests/test_redis.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from testcontainers.redis import RedisContainer, AsyncRedisContainer
44
import pytest
5+
import redis
56

67

78
def test_docker_run_redis():
@@ -24,6 +25,16 @@ def test_docker_run_redis_with_password():
2425
assert client.get("hello") == "world"
2526

2627

28+
def test_docker_run_start_fails(monkeypatch: pytest.MonkeyPatch):
29+
# Patch config to speed up the test.
30+
monkeypatch.setattr("testcontainers.core.config.testcontainers_config.max_tries", 0.3)
31+
monkeypatch.setattr("testcontainers.core.config.testcontainers_config.sleep_time", 0.02)
32+
# Use a bogus image to make the startup check fail.
33+
config = RedisContainer(image="hello-world")
34+
with pytest.raises(redis.exceptions.ConnectionError, match="Could not connect"):
35+
config.start()
36+
37+
2738
pytest.mark.usefixtures("anyio_backend")
2839

2940

0 commit comments

Comments
 (0)