chore: implement more robust wait strategies in testcontainers services

This commit is contained in:
Manuel de la Peña
2025-02-18 17:58:47 +01:00
parent d3c0d39dc8
commit 0c2d884898
7 changed files with 45 additions and 7 deletions

View File

@@ -10,7 +10,6 @@ import (
"github.com/stretchr/testify/require"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/postgres"
"github.com/testcontainers/testcontainers-go/wait"
)
const (
@@ -36,11 +35,7 @@ func newTestStore(t testing.TB) (*Storage, error) {
postgres.WithUsername(postgresUser),
postgres.WithPassword(postgresPass),
postgres.WithDatabase(postgresDatabase),
testcontainers.WithWaitStrategy(
// First, we wait for the container to log readiness twice.
// This is because it will restart itself after the first startup.
wait.ForLog("database system is ready to accept connections").WithOccurrence(2),
),
postgres.BasicWaitStrategies(),
)
testcontainers.CleanupContainer(t, c)
require.NoError(t, err)