Documentation
¶
Overview ¶
Package testutils provides shared integration-test helpers.
Index ¶
- func SkipWithoutDocker(t testing.TB)
- type ContainerExecutor
- type Mailpit
- type MinIO
- type Postgres
- func (p *Postgres) ContainerID() string
- func (p *Postgres) CopyFileFromContainer(ctx context.Context, containerPath, hostPath string) error
- func (p *Postgres) CopyFileToContainer(ctx context.Context, hostPath, containerPath string) error
- func (p *Postgres) Exec(ctx context.Context, cmd []string) (int, string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SkipWithoutDocker ¶
SkipWithoutDocker skips the test when no healthy Docker provider is available. This lets container-based integration tests skip on hosts without a daemon — e.g. GitHub-hosted macOS runners, which lack nested virtualization and cannot run a Linux VM for Docker. It mirrors testcontainers.SkipIfProviderIsNotHealthy but accepts testing.TB.
Types ¶
type ContainerExecutor ¶
type ContainerExecutor struct {
PG *Postgres
}
ContainerExecutor runs the PostgreSQL client tools inside the test Postgres container. It structurally satisfies database.Executor, so tests can override database.DefaultExecutor without an import cycle.
Host/port flags are stripped so the tools connect over the container-local Unix socket (trusted auth); env is ignored for the same reason. Files cross the boundary via container copy.
func (*ContainerExecutor) PGDump ¶
func (e *ContainerExecutor) PGDump(ctx context.Context, _ []string, args []string, outputPath string) error
PGDump dumps to a path inside the container, then copies the file to the host output path.
type Mailpit ¶
type Mailpit struct {
// SMTPAddr is the host:port of the SMTP listener.
SMTPAddr string
// APIURL is the HTTP API base URL (http://host:port).
APIURL string
// Username and Password are the relay credentials.
Username string
Password string
}
Mailpit is a running Mailpit container.
type MinIO ¶
type MinIO struct {
// Endpoint is the S3 API address (http://host:port).
Endpoint string
// AccessKey and Secret are the root credentials.
AccessKey string
Secret string
}
MinIO is a running S3-compatible object store container.
type Postgres ¶
type Postgres struct {
// DSN is the connection string of the shared instance.
DSN string
// contains filtered or unexported fields
}
Postgres is a running Postgres container for integration tests.
func StartPostgres ¶
StartPostgres returns the shared Postgres container for the test binary.
func (*Postgres) ContainerID ¶
ContainerID returns the container ID for debugging.
func (*Postgres) CopyFileFromContainer ¶
CopyFileFromContainer copies a file from the container to the host.
func (*Postgres) CopyFileToContainer ¶
CopyFileToContainer copies a file from host to container.