testinfra

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package testinfra is the extendable integration-test harness for a servicepack app. Its baseline builds the servicepack image from the repo Dockerfile and runs it, so a test exercises the real, containerized application with whatever services it registers, and nothing more.

Extend it with the external dependencies your services need (a database, a cache, a broker via testcontainers-go): give Infra a field, start it in Setup, wire the app container to it, and tear it down in Teardown. The DIND runner already supports this: DEV_RUN_DIND uses the host network, so testcontainers' host-published ports are reachable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Infra

type Infra struct {
	App testcontainers.Container
}

Infra holds the containers a test package brought up. At the baseline that is just the application image; extend it with one field per external dependency (for example: Postgres *PostgresResource) as your services grow.

func Setup

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

Setup builds the app image from the repo Dockerfile and starts it with the run command, blocking until the app logs that it is running. On failure it returns the error with nothing left running to leak.

func (*Infra) Teardown

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

Teardown terminates every started container. Idempotent and best-effort: safe to call from a Setup failure path and from a test's cleanup.

Jump to

Keyboard shortcuts

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