From 372c48b2ce472b80d1024375b67726394ef2f170 Mon Sep 17 00:00:00 2001 From: appleboy Date: Sun, 19 Jan 2025 22:08:39 +0800 Subject: [PATCH] refactor: improve NATS container startup strategy and testing reliability - Change the NATS container waiting strategy from executing a wget command to waiting for a specific log message "Server is ready" Signed-off-by: appleboy --- nats_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/nats_test.go b/nats_test.go index 9c89410..ad4f7f7 100644 --- a/nats_test.go +++ b/nats_test.go @@ -39,9 +39,7 @@ func setupNatsContainer(ctx context.Context, t *testing.T) (testcontainers.Conta req := testcontainers.ContainerRequest{ Image: "nats:2.10", ExposedPorts: []string{"4222/tcp"}, - WaitingFor: wait.NewExecStrategy( - []string{"wget", "http://localhost:8222/healthz", "-q", "-S", "-O", "-"}, - ), + WaitingFor: wait.ForLog("Server is ready"), } redisC, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{ ContainerRequest: req,