Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ require (
github.com/jackc/pgx/v5 v5.11.0
github.com/joho/godotenv v1.5.1
github.com/stretchr/testify v1.12.1
github.com/testcontainers/testcontainers-go v0.44.0
github.com/testcontainers/testcontainers-go/modules/postgres v0.44.0
go.opentelemetry.io/otel v1.46.0
go.opentelemetry.io/otel/metric v1.46.0
Expand Down Expand Up @@ -108,6 +107,7 @@ require (
github.com/shirou/gopsutil/v4 v4.26.6 // indirect
github.com/sirupsen/logrus v1.9.4 // indirect
github.com/stretchr/objx v0.5.3 // indirect
github.com/testcontainers/testcontainers-go v0.44.0 // indirect
github.com/tklauser/go-sysconf v0.4.0 // indirect
github.com/tklauser/numcpus v0.12.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
Expand Down
17 changes: 4 additions & 13 deletions internal/core/repository/postgres/session_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ import (

"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/postgres"
"github.com/testcontainers/testcontainers-go/wait"

"github.com/duynhlab/pkg/idempotency"

Expand All @@ -38,20 +36,13 @@ func newTestDB(t *testing.T) *pgxpool.Pool {
t.Helper()
ctx := context.Background()

container, err := postgres.Run(ctx, "postgres:16-alpine",
container, err := postgres.Run(ctx, "postgres:18-alpine",
postgres.WithDatabase("checkout"),
postgres.WithUsername("checkout"),
postgres.WithPassword("secret"),
// The postgres entrypoint starts the server twice (initdb, then the
// real start) and the port already listens during the first — waiting
// on the port races the restart window and connects die with
// "connection reset by peer". Wait for the SECOND ready line instead
// (same strategy as payment-service).
testcontainers.WithWaitStrategy(
wait.ForLog("database system is ready to accept connections").
WithOccurrence(2).
WithStartupTimeout(90*time.Second),
),
// Ready twice (initdb restarts the server once), then the published
// port: the module's own strategy, so a test never races the restart.
postgres.BasicWaitStrategies(),
)
if err != nil {
t.Fatalf("start postgres container: %v", err)
Expand Down
Loading