testing

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package testing provides test helpers for chit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EchoProcessor

func EchoProcessor() chit.Processor

EchoProcessor returns a processor that echoes the input as a response.

func YieldingProcessor

func YieldingProcessor(prompt string, finalResponse string) chit.Processor

YieldingProcessor returns a processor that yields on the first call and responds on the second call (via continuation).

Types

type CollectingEmitter

type CollectingEmitter struct {
	Messages  []chit.Message
	Resources []chit.Resource
	// contains filtered or unexported fields
}

CollectingEmitter collects all emitted content for easy assertion.

func (*CollectingEmitter) Close

func (e *CollectingEmitter) Close() error

Close implements chit.Emitter.

func (*CollectingEmitter) Content

func (e *CollectingEmitter) Content() string

Content returns all emitted message content concatenated.

func (*CollectingEmitter) Emit

Emit implements chit.Emitter.

func (*CollectingEmitter) Push

func (e *CollectingEmitter) Push(_ context.Context, resource chit.Resource) error

Push implements chit.Emitter.

type MockEmitter

type MockEmitter struct {
	// EmitFunc is called when Emit is invoked.
	EmitFunc func(ctx context.Context, msg chit.Message) error

	// PushFunc is called when Push is invoked.
	PushFunc func(ctx context.Context, resource chit.Resource) error

	// CloseFunc is called when Close is invoked.
	CloseFunc func() error

	// Messages records all emitted messages.
	Messages []chit.Message

	// Resources records all pushed resources.
	Resources []chit.Resource

	// Closed indicates whether Close was called.
	Closed bool
	// contains filtered or unexported fields
}

MockEmitter is a test implementation of chit.Emitter.

func (*MockEmitter) Close

func (m *MockEmitter) Close() error

Close implements chit.Emitter.

func (*MockEmitter) Emit

func (m *MockEmitter) Emit(ctx context.Context, msg chit.Message) error

Emit implements chit.Emitter.

func (*MockEmitter) Push

func (m *MockEmitter) Push(ctx context.Context, resource chit.Resource) error

Push implements chit.Emitter.

type MockProcessor

type MockProcessor struct {
	// ProcessFunc is called when Process is invoked.
	// Set this to control the mock's behavior.
	ProcessFunc func(ctx context.Context, input string, history []chit.Message) (chit.Result, error)

	// Calls records all calls to Process for verification.
	Calls []ProcessCall
	// contains filtered or unexported fields
}

MockProcessor is a test implementation of chit.Processor.

func (*MockProcessor) Process

func (m *MockProcessor) Process(ctx context.Context, input string, history []chit.Message) (chit.Result, error)

Process implements chit.Processor.

type ProcessCall

type ProcessCall struct {
	Input   string
	History []chit.Message
}

ProcessCall records a single call to Process.

Jump to

Keyboard shortcuts

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