Help us shape the future of Go! Take the 2026 Go Developer Survey

testkit

package
v0.5.3 Latest Latest
Warning

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

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

Documentation

Overview

Package testkit exercises the production Foundry lifecycle with test-owned cleanup. Feature-specific fakes and clients are added with those features.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Namespace

func Namespace(t testing.TB) keyspace.Namespace

Namespace returns an independent test identity for explicitly shared cache, queue and coordination backends. It does not delete keys or flush a backend. Keep and reuse the returned value within one application assembly.

func Plugins

func Plugins(t testing.TB, plugins ...foundation.Plugin) *foundation.App

Plugins runs explicitly linked plugins through production Build/Start and the existing test-owned cleanup. For application provider dependencies or custom runtime options use Start with a fully assembled builder instead.

func Start

func Start(t testing.TB, builder *foundation.Builder) *foundation.App

Start builds and boots the supplied production bootstrap and registers cleanup before startup, so partial boot failures also release acquired resources.

func TrackExternalInputs

func TrackExternalInputs(t testing.TB)

TrackExternalInputs makes Go's test cache depend on make's current source/tool fingerprint. Use it in tests invoking a compiler, generator, gopls or Node over external-module inputs. Make computes the fingerprint once per invocation. For a direct go test invocation without make, use -count=1 for these gates: Go does not track child file reads outside the parent test's module root.

Types

type Clock

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

Clock is a concurrency-safe, explicitly controlled application clock. It does not alter Go timers or context deadlines, so freezing it cannot hang shutdown.

func NewClock

func NewClock(now time.Time) *Clock

NewClock creates a test clock initialized to the supplied instant in UTC.

func (*Clock) Advance

func (c *Clock) Advance(duration time.Duration)

Advance advances the clock under its mutex.

func (*Clock) Now

func (c *Clock) Now() time.Time

Now returns the current test time under a read lock.

func (*Clock) Set

func (c *Clock) Set(now time.Time)

Set sets the clock to the supplied instant in UTC under its mutex.

Directories

Path Synopsis
Package application runs configured application kernels with test-owned cleanup.
Package application runs configured application kernels with test-owned cleanup.
Package auth provides test-owned production authentication scopes.
Package auth provides test-owned production authentication scopes.
Package dbassert asserts persisted state through typed query callbacks.
Package dbassert asserts persisted state through typed query callbacks.
Package email provides assertions for the opt-in memory email driver.
Package email provides assertions for the opt-in memory email driver.
Package events records explicitly selected production event listeners.
Package events records explicitly selected production event listeners.
Package factory builds typed ORM drafts and persists them through the ordinary model lifecycle.
Package factory builds typed ORM drafts and persists them through the ordinary model lifecycle.
Package http provides test-owned HTTP servers and bounded clients.
Package http provides test-owned HTTP servers and bounded clients.
Package httpclient supplies deterministic outbound HTTP transports for tests.
Package httpclient supplies deterministic outbound HTTP transports for tests.
Package jobs supplies an explicitly local production queue authority for tests.
Package jobs supplies an explicitly local production queue authority for tests.
Package notifications supplies a recording custom-channel transport for tests.
Package notifications supplies a recording custom-channel transport for tests.
Package postgres provides opt-in, non-destructive PostgreSQL acceptance helpers.
Package postgres provides opt-in, non-destructive PostgreSQL acceptance helpers.
application
Package application binds retained PostgreSQL scopes to production application settings.
Package application binds retained PostgreSQL scopes to production application settings.
Package redis provides opt-in, non-destructive Redis acceptance helpers.
Package redis provides opt-in, non-destructive Redis acceptance helpers.
Package storage provides a shared behavioral contract for storage adapters.
Package storage provides a shared behavioral contract for storage adapters.
Package websocket provides a bounded protocol client for independent consumer tests.
Package websocket provides a bounded protocol client for independent consumer tests.

Jump to

Keyboard shortcuts

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