Documentation
¶
Overview ¶
Package providertest provides a test contract kit for model provider implementations. It defines a Script type that describes expected provider behavior and a Run function that validates a provider against those specifications.
The kit is provider-agnostic: adapters supply format-specific bodies through Script fields, while Run validates the contract invariants (retry behavior, token mapping, usage consistency).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Script ¶
type Script struct {
// CompleteResponse is the JSON body the fake server returns for non-streaming Complete calls.
// Must be a valid model.Response JSON.
CompleteResponse string
// StreamChunks is a slice of SSE data lines for streaming tests.
// Each string is the "data: " payload for an SSE event (SSE framing is added by Run).
StreamChunks []string
// ExpectedModel is the model identifier the adapter must send in the request.
ExpectedModel string
// ExpectedTools controls whether to verify tools are present in the adapter's request.
ExpectedTools bool
// ToolCallResponse is the JSON response for a tool call test.
// If non-empty, enables the tool-call roundtrip subtest.
ToolCallResponse string
// ToolResultFinalResponse is the JSON response the server returns after receiving
// a tool result. Used in the tool-call roundtrip subtest, step (c).
ToolResultFinalResponse string
// UsageInputTokens is the expected InputTokens count in the response.
UsageInputTokens int
// UsageOutputTokens is the expected OutputTokens count in the response.
UsageOutputTokens int
// Validate is an optional hook called for each HTTP request with (request, body bytes).
// Return an error to fail the request; returning nil allows it to proceed.
Validate func(*http.Request, []byte) error
// Handler is an optional custom HTTP handler that replaces the default behavior.
// If set, Validate is ignored and Handler receives all requests.
Handler http.Handler
}
Script describes the expected behavior of a model provider for a test roundtrip. Adapters fill in format-specific request/response bodies; Run validates invariants.
Click to show internal directories.
Click to hide internal directories.