Skip to content

Commit 77c7a0d

Browse files
committed
refactor: refactor Redis initialization and worker connection setup
- Add context initialization and container request setup for Redis in `TestRedisDefaultFlow` - Replace `WithAddr(host01)` with `WithConnectionString(endpoint)` in `NewWorker` initialization Signed-off-by: appleboy <[email protected]>
1 parent 529479a commit 77c7a0d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

redis_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,26 @@ func TestWithRedis(t *testing.T) {
5454
}
5555

5656
func TestRedisDefaultFlow(t *testing.T) {
57+
ctx := context.Background()
58+
req := testcontainers.ContainerRequest{
59+
Image: "redis:6",
60+
ExposedPorts: []string{"6379/tcp"},
61+
WaitingFor: wait.ForLog("Ready to accept connections"),
62+
}
63+
redisC, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
64+
ContainerRequest: req,
65+
Started: true,
66+
})
67+
require.NoError(t, err)
68+
69+
endpoint, err := redisC.Endpoint(ctx, "")
70+
require.NoError(t, err)
71+
5772
m := &mockMessage{
5873
Message: "foo",
5974
}
6075
w := NewWorker(
61-
WithAddr(host01),
76+
WithConnectionString(endpoint),
6277
WithChannel("test"),
6378
)
6479
q, err := queue.NewQueue(

0 commit comments

Comments
 (0)