testhelpers

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertMapHasKey

func AssertMapHasKey(t *testing.T, m map[string]interface{}, key string)

AssertMapHasKey checks if a map has a specific key with a descriptive error message

func GetMapValue

func GetMapValue[T any](t *testing.T, m map[string]interface{}, key string) (T, bool)

GetMapValue gets a map value and returns it if it's of the expected type, otherwise returns false

func RequireEnv

func RequireEnv(t *testing.T, envVar string) string

RequireEnv requires the specified environment variable to be set, returns its value

func RequireMapValue

func RequireMapValue[T any](t *testing.T, m map[string]interface{}, key string) T

RequireMapValue gets a map value and requires it to be of the expected type

func SkipIfNoEnv

func SkipIfNoEnv(t *testing.T, envVar string)

SkipIfNoEnv skips the test if the specified environment variable is not set

Types

type MockAgent

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

MockAgent is a simple function-based mock agent for testing examples

func NewMockAgent

func NewMockAgent(name string) *MockAgent

NewMockAgent creates a new mock agent with the given name

func (*MockAgent) Batch

func (m *MockAgent) Batch(ctx context.Context, inputs []*core.AgentInput) ([]*core.AgentOutput, error)

Batch is not implemented for examples (not needed)

func (*MockAgent) Capabilities

func (m *MockAgent) Capabilities() []string

Capabilities returns the agent capabilities

func (*MockAgent) Description

func (m *MockAgent) Description() string

Description returns the agent description

func (*MockAgent) Invoke

func (m *MockAgent) Invoke(ctx context.Context, input *core.AgentInput) (*core.AgentOutput, error)

Invoke executes the mock agent logic

func (*MockAgent) Name

func (m *MockAgent) Name() string

Name returns the agent name

func (*MockAgent) Pipe

Pipe is not implemented for examples

func (*MockAgent) SetInvokeFn

func (m *MockAgent) SetInvokeFn(fn func(ctx context.Context, input *core.AgentInput) (*core.AgentOutput, error))

SetInvokeFn sets a custom invoke function for this mock agent

func (*MockAgent) Stream

func (m *MockAgent) Stream(ctx context.Context, input *core.AgentInput) (<-chan core.StreamChunk[*core.AgentOutput], error)

Stream is not implemented for examples (not needed)

func (*MockAgent) WithCallbacks

func (m *MockAgent) WithCallbacks(callbacks ...core.Callback) core.Runnable[*core.AgentInput, *core.AgentOutput]

WithCallbacks returns the agent (no-op for mock)

func (*MockAgent) WithConfig

WithConfig returns the agent (no-op for mock)

Jump to

Keyboard shortcuts

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