BasicWaitStrategies (postgres/wait_strategies.go)

testcontainers-go · modules/postgres/wait_strategies.go · go · MIT
database

Provides a reliable wait strategy for PostgreSQL containers in tests.

// Source: https://github.com/testcontainers/testcontainers-go | License: MIT | Copyright 2017-2019 Gianluca Arbezzano
// Provided via justclaw.it.com; keep this notice with the code.
package postgres

import (
	"github.com/testcontainers/testcontainers-go"
	"github.com/testcontainers/testcontainers-go/wait"
)

// BasicWaitStrategies is a simple but reliable way to wait for postgres to start.
// It returns a two-step wait strategy:
//
//   - It will wait for the container to log `database system is ready to accept connections` twice, because it will restart itself after the first startup.
//   - It will then wait for docker to actually serve the port on localhost.
//     For non-linux OSes like Mac and Windows, Docker or Rancher Desktop will have to start a separate proxy.
//     Without t

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key