testutil

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockLLMServer

type MockLLMServer struct {
	Server    *httptest.Server
	Responses []MockResponse
	Requests  []MockRequest
	// contains filtered or unexported fields
}

MockLLMServer provides a configurable mock LLM API server for testing.

func NewMockLLMServer

func NewMockLLMServer(t *testing.T, responses ...MockResponse) *MockLLMServer

NewMockLLMServer creates a mock server that returns canned responses in order.

func (*MockLLMServer) ContainsString

func (m *MockLLMServer) ContainsString(s string) bool

ContainsString checks if any request body contains the given string.

func (*MockLLMServer) LastRequest

func (m *MockLLMServer) LastRequest() MockRequest

LastRequest returns the most recent request body.

func (*MockLLMServer) RequestCount

func (m *MockLLMServer) RequestCount() int

RequestCount returns how many requests were made.

func (*MockLLMServer) URL

func (m *MockLLMServer) URL() string

URL returns the base URL of the mock server.

type MockRequest

type MockRequest struct {
	Method string
	Path   string
	Body   map[string]interface{}
}

MockRequest records a request made to the mock server.

type MockResponse

type MockResponse struct {
	Content    string
	ToolUse    []ToolUseBlock
	StopReason string
	StatusCode int
}

MockResponse defines a canned response from the mock LLM.

func ErrorResponse

func ErrorResponse(statusCode int) MockResponse

ErrorResponse creates a mock error response.

func SimpleTextResponse

func SimpleTextResponse(text string) MockResponse

SimpleTextResponse creates a mock response with just text content.

func ToolUseResponse

func ToolUseResponse(toolName string, input map[string]interface{}) MockResponse

ToolUseResponse creates a mock response that calls a tool.

type ToolUseBlock

type ToolUseBlock struct {
	ID    string
	Name  string
	Input map[string]interface{}
}

ToolUseBlock represents a tool call in the response.

Jump to

Keyboard shortcuts

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