Documentation
¶
Index ¶
- Constants
- func IsLoopbackUnavailable(err error) bool
- func ListenLoopback(t testing.TB) net.Listener
- func NewLoopbackHTTPServer(t testing.TB, handler http.Handler) *httptest.Server
- func SkipIfLoopbackUnavailable(t testing.TB, err error)
- type MockLLMServer
- type MockRequest
- type MockResponse
- type ToolUseBlock
Constants ¶
const ( LoopbackHost = netutil.LoopbackHost LoopbackDynamicAddr = netutil.LoopbackDynamicAddr LoopbackNoProxy = netutil.LoopbackNoProxy )
Variables ¶
This section is empty.
Functions ¶
func IsLoopbackUnavailable ¶ added in v0.2.1
func NewLoopbackHTTPServer ¶ added in v0.2.1
func SkipIfLoopbackUnavailable ¶ added in v0.2.1
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 ¶
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 ¶
ToolUseBlock represents a tool call in the response.