agenttest

package
v0.3.13 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package agenttest provides reusable contract-test machinery for the interfaces declared in sdk/agent — agent.Decider and agent.Observer today, more if the agent package grows.

Mirrors sdk/engine/enginetest's layout: ONE xxxtest sub-package per parent package, multiple suites within when the parent declares multiple contractual interfaces. See io/iotest, net/http/httptest, gocloud.dev/blob/drivertest for the same pattern in the wider Go ecosystem.

What lives here

What does NOT live here

Decider / Observer business logic — those are per-implementation unit tests. The suites only enforce "agent.Run can call you safely without crashing the run".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeciderSuite

func DeciderSuite(t *testing.T, f DeciderFactory, caps ...DeciderCapabilities)

DeciderSuite runs every applicable contract subtest against deciders produced by f.

func ObserverSuite

func ObserverSuite(t *testing.T, f ObserverFactory, caps ...ObserverCapabilities)

ObserverSuite runs every applicable contract subtest against observers produced by f.

Types

type DeciderCapabilities

type DeciderCapabilities struct {
	// SkipMutationCheck is true when the decider intentionally
	// mutates *Result (extremely rare — the interface comment
	// says "MUST NOT mutate res"; this knob exists only for
	// deciders that document a deliberate breach for migration
	// purposes).
	SkipMutationCheck bool

	// SkipAllStatusProbe is true for deciders that legitimately
	// only handle a subset of statuses and panic on others. The
	// suite then skips the cross-status probe; the decider is
	// expected to ship its own focused unit tests.
	SkipAllStatusProbe bool
}

DeciderCapabilities lets a decider opt out of subtests that don't apply. Most deciders pass the zero value (= every subtest runs).

type DeciderFactory

type DeciderFactory func() agent.Decider

DeciderFactory builds a fresh agent.Decider for each subtest. The suite invokes it once per case so subtests do not share decider state.

type ObserverCapabilities

type ObserverCapabilities struct {
	// SkipMutationCheck is true for observers that intentionally
	// mutate the *Request / *Result they receive. The interface
	// godoc says "MUST treat as read-only"; this knob exists only
	// for the rare migration shim that documents a deliberate
	// breach.
	SkipMutationCheck bool

	// SkipPromptReturnCheck is true for observers that legitimately
	// block (e.g. a synchronous flush observer the caller knows
	// about). The interface godoc says "blocking blocks the run",
	// so the suite enforces a 2s upper bound by default.
	SkipPromptReturnCheck bool
}

ObserverCapabilities lets observers opt out of subtests that don't apply. Most observers pass the zero value.

type ObserverFactory

type ObserverFactory func() agent.Observer

ObserverFactory builds a fresh agent.Observer for each subtest.

Jump to

Keyboard shortcuts

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