chaostest

package
v1.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package chaostest provides testing.TB integration helpers for chaotic. The most-used function is New, which returns a fresh engine bound to the test's t.Cleanup so faults from one test never leak into another.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertEventsExhausted

func AssertEventsExhausted(t testing.TB, eng *engine.Engine)

AssertEventsExhausted fails t if any named rule on eng has not fired at least once. Useful for asserting "every chaos rule I configured was actually exercised by my test".

func AssertHits

func AssertHits(t testing.TB, eng *engine.Engine, ruleName string, want int)

AssertHits fails t with a clear message if eng has not fired ruleName exactly want times.

func New

func New(t testing.TB, opts ...engine.Option) *engine.Engine

New returns an engine that resets itself when t finishes. Safe for t.Parallel because every test gets its own engine.

Types

type Event added in v1.4.0

type Event struct {
	Fired  bool
	Rule   string
	Op     engine.Op
	Reason string
}

Event is one observed engine decision. Fired distinguishes a RuleFired event (Fired=true, Reason="") from a RuleSkipped event (Fired=false, Reason set).

type Recorder added in v1.4.0

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

Recorder is an engine.Observer that records events for assertions. Attach it with engine.WithObserver. Safe for concurrent use. Methods run on the request path. A Recorder is an instance - never share one across engines you want to assert independently.

func NewRecorder added in v1.4.0

func NewRecorder() *Recorder

NewRecorder returns an empty Recorder.

func (*Recorder) Events added in v1.4.0

func (r *Recorder) Events() []Event

Events returns a copy of all recorded events in order.

func (*Recorder) Fired added in v1.4.0

func (r *Recorder) Fired(ruleName string) []Event

Fired returns the fired events for ruleName (or all fired events if "").

func (*Recorder) RuleFired added in v1.4.0

func (r *Recorder) RuleFired(name string, op engine.Op, _ engine.Action)

RuleFired adds an event of fired rule to the recorder.

func (*Recorder) RuleSkipped added in v1.4.0

func (r *Recorder) RuleSkipped(name string, op engine.Op, reason string)

RuleSkipped adds an event of skipped rule to the recorder.

func (*Recorder) Skipped added in v1.4.0

func (r *Recorder) Skipped(ruleName string) []Event

Skipped returns the skipped events for ruleName (or all skips if "").

Directories

Path Synopsis
Package quick provides opinionated one-line shortcuts for the most common chaos test setups.
Package quick provides opinionated one-line shortcuts for the most common chaos test setups.

Jump to

Keyboard shortcuts

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