fix(store): postgres.BasicWaitStrategies() — устраняет flaky first-run на macOS

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-03 14:04:23 +07:00
parent 5588e10e05
commit 9c29d40269
+3 -5
View File
@@ -3,11 +3,9 @@ package store
import ( import (
"context" "context"
"testing" "testing"
"time"
"github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/postgres" "github.com/testcontainers/testcontainers-go/modules/postgres"
"github.com/testcontainers/testcontainers-go/wait"
) )
// startPostgres spins up an ephemeral PostgreSQL, applies migrations, // startPostgres spins up an ephemeral PostgreSQL, applies migrations,
@@ -15,13 +13,13 @@ import (
func startPostgres(t *testing.T) string { func startPostgres(t *testing.T) string {
t.Helper() t.Helper()
ctx := context.Background() ctx := context.Background()
// BasicWaitStrategies включает ForLog(...)x2 И ForListeningPort — второй
// критичен на macOS/Windows Docker Desktop (иначе flaky first-run).
container, err := postgres.Run(ctx, "postgres:16-alpine", container, err := postgres.Run(ctx, "postgres:16-alpine",
postgres.WithDatabase("dns_ar_test"), postgres.WithDatabase("dns_ar_test"),
postgres.WithUsername("test"), postgres.WithUsername("test"),
postgres.WithPassword("test"), postgres.WithPassword("test"),
testcontainers.WithWaitStrategy( postgres.BasicWaitStrategies(),
wait.ForLog("database system is ready to accept connections").
WithOccurrence(2).WithStartupTimeout(60*time.Second)),
) )
if err != nil { if err != nil {
t.Fatalf("start postgres: %v", err) t.Fatalf("start postgres: %v", err)