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:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user