testkit

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResourceID

func ResourceID(prefix string) string

ResourceID returns a resource ID under the prefix that no other spec carries, so the specs share one database without sharing a resource.

Types

type Dependency

type Dependency interface {
	Start(ctx context.Context, injector do.Injector) error
	Stop(ctx context.Context) error
}

Dependency is infrastructure the service under test needs. Start brings it up and puts what specs arrange with, such as a database connection, into the injector.

type Isolator added in v0.6.0

type Isolator interface {
	Isolate(ctx context.Context) (settings map[string]any, release func(context.Context) error, err error)
}

type Options

type Options struct {
	// Modules has the shape of a service's own module list constructor.
	Modules func(conf app.Module) []app.Module

	// Dependencies come up before the service and merge their settings into
	// its config.
	Dependencies []Dependency

	// Settings has the shape of the service's config file. It overrides what
	// Boot and the dependencies set.
	Settings map[string]any
}

type SettingsProvider

type SettingsProvider interface {
	Settings() map[string]any
}

SettingsProvider yields the settings a started dependency hands the service.

type Suite

type Suite struct {
	// contains filtered or unexported fields
}

func Boot

func Boot(ctx context.Context, opts Options) (*Suite, error)

Boot starts the dependencies, then runs a service in this process and waits for its health service to answer. Specs reach it over a real socket.

func (*Suite) Addr

func (s *Suite) Addr() string

func (*Suite) Config added in v0.6.0

func (s *Suite) Config() app.Module

func (*Suite) Conn

func (s *Suite) Conn() *grpc.ClientConn

func (*Suite) DialWithToken added in v0.5.0

func (s *Suite) DialWithToken(token string) (*grpc.ClientConn, error)

DialWithToken opens a connection that sends the token as `authorization: Bearer <token>` on every call. The caller closes it.

func (*Suite) Injector

func (s *Suite) Injector() do.Injector

Injector holds what the dependencies provided for arranging state. The service's own injector stays out of reach.

func (*Suite) Isolated added in v0.6.0

func (s *Suite) Isolated(ctx context.Context, overrides map[string]any) (*Suite, error)

func (*Suite) Rebooted

func (s *Suite) Rebooted(ctx context.Context, overrides map[string]any) (*Suite, error)

Rebooted runs a second service on the dependencies of the suite, with the overrides on the settings the suite booted with.

func (*Suite) Stop

func (s *Suite) Stop() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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