sat

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sat provides a System Acceptance Test framework that orchestrates postgres, database migrations, and services under test (SUTs).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	SUTS                 []SUT
	Initializer          SUT
	Migrator             SUT
	PostgresServerConfig PostgresServerConfig
	EnvironmentVariables map[string]string
	Nats                 bool
	Debug                bool

	// NatsSubjects are buffered by [SAT.NatsStore] for the lifetime of the run, so that a test
	// can assert on events the RPCs triggering them do not wait for. They may contain the NATS
	// wildcards `*` and `>`. Requires Nats.
	NatsSubjects []string
}

Config holds all configuration needed to set up a SAT environment, including the services to test, database setup binaries, and environment variables.

type PostgresServerConfig

type PostgresServerConfig struct {
	Host     string
	Port     int
	User     string
	Password string
}

PostgresServerConfig holds connection details for the test Postgres instance.

type SAT

type SAT struct {
	PostgresServer *postgrestestserver.Server

	// NatsStore buffers everything published to Config.NatsSubjects, or is nil if none were
	// given. It subscribes before any SUT starts, so events emitted during boot are caught too.
	NatsStore *natsteststore.Nats
	// contains filtered or unexported fields
}

SAT orchestrates the lifecycle of all binaries and the Postgres server required for system acceptance testing.

func New

func New(config *Config) *SAT

New creates a SAT instance. It starts Postgres (if a migrator is configured), runs the database initializer and migrator jobs, then starts all SUTs.

func (*SAT) Cleanup

func (s *SAT) Cleanup()

Cleanup tears down everything Start brought up. It is safe to call on a partially started SAT, which is what a failing Start leaves behind.

func (*SAT) GetNatsClient

func (s *SAT) GetNatsClient(ctx context.Context) (*nats.Client, error)

func (*SAT) GetPostgresClient

func (s *SAT) GetPostgresClient(ctx context.Context, database string) (*postgres.Client, error)

GetPostgresClient returns a started client connected to the given database on this SAT's Postgres server, as its superuser, which can reach any database the migrator created. Clients are cached per database and closed by SAT.Cleanup, so callers need not close them.

func (*SAT) Start

func (s *SAT) Start(ctx context.Context) error

func (*SAT) WithLogger

func (s *SAT) WithLogger(logger *slog.Logger) *SAT

WithLogger sets this SAT's logger.

type SUT

type SUT struct {
	Name string
	Path string
	Port int
	Args []string
}

SUT represents a Service Under Test, i.e. a binary that will be started and monitored during the acceptance test run.

Jump to

Keyboard shortcuts

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