testinfra

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package testinfra brings up the real external dependencies chatz uses (a real Postgres via testcontainers-go) for integration tests. It runs the SAME connection + migration path as production (internal/pkg/db.Connect) so tests catch divergence between test setup and prod setup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Infra

type Infra struct {
	PostgresContainer *tcpostgres.PostgresContainer
	Database          *db.Handle
	PG                *postgresql.Postgresql
}

Infra holds the running containers + connections for a test package. Call Teardown when done (typically from TestMain wrapping m.Run).

func Setup

func Setup(ctx context.Context) (*Infra, error)

Setup brings up Postgres and runs chatz's migrations against it. Every error path tears down what was started so no container leaks.

func (*Infra) Teardown

func (i *Infra) Teardown(ctx context.Context)

Teardown closes connections then terminates containers. Idempotent — safe to call from any failure path inside Setup. Cleanup errors are best-effort: the process is exiting, there is nothing to recover.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL