Documentation
¶
Overview ¶
Package testutil provides shared test helpers for the goagent module.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockEmbedder ¶
type MockEmbedder struct {
Dim int // vector dimension; defaults to 16 when zero
}
MockEmbedder generates deterministic embeddings via an LCG seeded with the FNV-32a hash of the text content. Makes no API calls. The same text always produces the same normalized vector. Use in unit tests that need similarity search without external services.
func (*MockEmbedder) Embed ¶
func (m *MockEmbedder) Embed(_ context.Context, blocks []goagent.ContentBlock) ([]float32, error)
Embed returns a deterministic unit-length vector for the text content of blocks. Returns vector.ErrNoEmbeddeableContent when blocks contain no text.
type MockLongTermMemory ¶
type MockLongTermMemory struct {
// contains filtered or unexported fields
}
MockLongTermMemory is a thread-safe LongTermMemory implementation for tests.
func NewMockLongTermMemory ¶
func NewMockLongTermMemory() *MockLongTermMemory
NewMockLongTermMemory creates a MockLongTermMemory that stores all messages and returns an empty slice from Retrieve by default.
func NewMockLongTermMemoryWithErrors ¶
func NewMockLongTermMemoryWithErrors(storeErr, retrieveErr error) *MockLongTermMemory
NewMockLongTermMemoryWithErrors creates a MockLongTermMemory that returns the given errors from Store and Retrieve respectively.
func NewMockLongTermMemoryWithRetrieve ¶
func NewMockLongTermMemoryWithRetrieve(retrieved ...goagent.Message) *MockLongTermMemory
NewMockLongTermMemoryWithRetrieve creates a MockLongTermMemory that returns the given messages (with Score 0.0) as the fixed response to every Retrieve call.
func (*MockLongTermMemory) AllStored ¶
func (m *MockLongTermMemory) AllStored() []goagent.Message
AllStored returns all messages passed to Store as a defensive copy.
func (*MockLongTermMemory) Retrieve ¶
func (m *MockLongTermMemory) Retrieve(_ context.Context, _ []goagent.ContentBlock, _ int) ([]goagent.ScoredMessage, error)
Retrieve returns the fixed retrieved slice. Returns retrieveErr if configured.
type MockMemory ¶
type MockMemory struct {
// contains filtered or unexported fields
}
MockMemory is a thread-safe ShortTermMemory implementation for tests. It records all Append calls and can be configured to return errors.
func NewMockMemory ¶
func NewMockMemory() *MockMemory
NewMockMemory creates a MockMemory with no pre-loaded history and no errors.
func NewMockMemoryWithErrors ¶
func NewMockMemoryWithErrors(appendErr, messagesErr error) *MockMemory
NewMockMemoryWithErrors creates a MockMemory that returns the given errors from Append and Messages respectively. Pass nil to not error on that method.
func NewMockMemoryWithHistory ¶
func NewMockMemoryWithHistory(msgs ...goagent.Message) *MockMemory
NewMockMemoryWithHistory creates a MockMemory pre-loaded with the given messages.
func (*MockMemory) All ¶
func (m *MockMemory) All() []goagent.Message
All returns all stored messages as a defensive copy.
type MockProvider ¶
type MockProvider struct {
// contains filtered or unexported fields
}
MockProvider is a thread-safe Provider that returns pre-configured responses in FIFO order. Use it in unit tests to avoid requiring a live LLM.
func NewMockProvider ¶
func NewMockProvider(responses ...goagent.CompletionResponse) *MockProvider
NewMockProvider creates a MockProvider that will return the given responses in order. If Complete is called more times than there are responses, it returns an error.
func (*MockProvider) Calls ¶
func (m *MockProvider) Calls() []goagent.CompletionRequest
Calls returns all requests received so far, in order. Safe to call after the test has finished.
func (*MockProvider) Complete ¶
func (m *MockProvider) Complete(_ context.Context, req goagent.CompletionRequest) (goagent.CompletionResponse, error)
Complete returns the next queued response. It is safe for concurrent use.
type MockTool ¶
type MockTool struct {
// contains filtered or unexported fields
}
MockTool is a Tool implementation for use in tests.
func NewMockTool ¶
NewMockTool creates a tool that always returns result as a text block with no error.
func NewMockToolWithError ¶
NewMockToolWithError creates a tool that always returns the given error.
func (*MockTool) Definition ¶
func (m *MockTool) Definition() goagent.ToolDefinition