testing

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package testing provides helpers for asserting on Actor behavior in unit tests. Not for use outside test code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultContext

func DefaultContext() context.Context

DefaultContext returns the standard test context. Centralized so future tweaks (e.g. attaching a logger) apply to every test that uses the harness.

func WaitFor

func WaitFor[Ctx any, Evt any](
	a *fate.Actor[Ctx, Evt],
	pred func(fate.Snapshot[Ctx]) bool,
	timeout time.Duration,
) (fate.Snapshot[Ctx], error)

WaitFor blocks until the actor's snapshot satisfies pred or the deadline expires. The default deadline is 1 second; override with a non-zero timeout argument.

Types

type Trace

type Trace[Ctx any] struct {
	Snapshots []fate.Snapshot[Ctx]
	// contains filtered or unexported fields
}

Trace returns a recorder that captures every snapshot emitted by the actor's Subscribe channel, in order. Useful for asserting on the sequence of states a test drives the actor through.

func NewTrace

func NewTrace[Ctx any, Evt any](a *fate.Actor[Ctx, Evt]) *Trace[Ctx]

NewTrace starts capturing snapshots from the actor immediately.

func (*Trace[Ctx]) Paths

func (t *Trace[Ctx]) Paths() []string

Paths returns the sequence of state-value paths observed by the trace. Convenient for one-line equality assertions in tests.

func (*Trace[Ctx]) Stop

func (t *Trace[Ctx]) Stop()

Stop unsubscribes the trace from the actor. Safe to call multiple times.

Jump to

Keyboard shortcuts

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