agenthookstest

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package agenthookstest provides the golden fixture corpus and a fake-provider harness so hook binaries built on agenthooks can be integration-tested in CI without the actual agents (DESIGN.md §10).

Index

Constants

This section is empty.

Variables

View Source
var FixturesFS embed.FS

Functions

func AssertNoOp

func AssertNoOp(tb testing.TB, provider agenthooks.Provider, res Result)

AssertNoOp fails unless the result is the provider's correct "no opinion" form — the round-trip property of DESIGN.md §5.4.

func Fixture

func Fixture(tb testing.TB, name string) []byte

Fixture returns one captured provider payload, e.g. "claude/pre_tool_use.json".

func FixtureDir

func FixtureDir(p agenthooks.Provider) string

FixtureDir maps a Provider to its fixture directory name.

func Fixtures

func Fixtures(tb testing.TB, provider string) map[string][]byte

Fixtures returns every fixture under one provider directory, keyed by filename.

Types

type FakeAgent

type FakeAgent struct {
	Provider agenthooks.Provider
	Binary   string
	Args     []string // defaults to the generated-config argv contract
	Env      []string // appended to the inherited environment
}

FakeAgent spawns a consumer binary exactly like a provider does: payload on stdin (or argv), provider env cross-set the way real agents cross-set it, and the provider's exit-code interpretation left to the caller.

func (FakeAgent) Invoke

func (f FakeAgent) Invoke(ctx context.Context, payload []byte) (Result, error)

Invoke runs the binary against one payload.

type Result

type Result struct {
	Stdout   []byte
	Stderr   string
	ExitCode int
}

Result captures one hook invocation's wire output.

func Invoke

func Invoke(tb testing.TB, r *agenthooks.Runner, provider agenthooks.Provider, payload []byte, extraArgs ...string) Result

Invoke runs the Runner in-process exactly as the generated config would: stdin payload, --provider flag, streams captured. For Cursor tool events construct the Runner with agenthooks.WithoutDedup() (or a per-test WithDedupDir) so cross-test markers can't collide. Tests that count handler invocations should also pass agenthooks.WithoutBackfill() (or an isolated WithDedupDir): prompt-implied events can synthesize a reporting-only prompt.submitted, keyed by machine-global session markers.

Jump to

Keyboard shortcuts

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