Documentation
¶
Overview ¶
Package dispatchtest holds what every host of dispatch.Dispatcher tests against: the exported contract (Contract), a recording fake for core tests (Fake), and a minimal HTTP host for tests that talk to an httptest server (HTTPHost).
Index ¶
- func AnthropicAuth(key, scheme string) http.Header
- func BearerAuth(key string) http.Header
- func Contract(t *testing.T, newH NewHarness)
- type Fake
- func (f *Fake) Do(_ context.Context, r dispatch.Request) (dispatch.Response, error)
- func (f *Fake) Pin() dispatch.Ref
- func (f *Fake) Price(_ context.Context, endpoint, model string, promptTokens int64) (dispatch.Price, bool)
- func (f *Fake) Release(ref dispatch.Ref)
- func (f *Fake) Sent() []dispatch.Request
- type HTTPHost
- type Harness
- type NewHarness
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnthropicAuth ¶
AnthropicAuth is the header an Anthropic-dialect key goes in: x-api-key, or a bearer token when scheme is "bearer" (gateways).
func Contract ¶
func Contract(t *testing.T, newH NewHarness)
Contract is what every host's Dispatcher must satisfy. A change in context-guru that breaks it fails here first, before it reaches a host.
Types ¶
type Fake ¶
type Fake struct {
Respond func(dispatch.Request) (dispatch.Response, error)
Prices func(endpoint, model string, promptTokens int64) (dispatch.Price, bool)
// contains filtered or unexported fields
}
Fake is a recording Dispatcher for core tests. Respond answers every Do on a pinned ref; Prices answers Price (nil: nothing is priced).
type HTTPHost ¶
type HTTPHost struct {
// contains filtered or unexported fields
}
HTTPHost is the smallest real host: it sends to the targets pinned on it, with the headers pinned with them. For tests (and live test tools) that talk to an httptest server or a real endpoint. It holds credentials in the clear and prices nothing — a production host masks what it holds and owns a rate table.
func NewHTTPHost ¶
func NewHTTPHost() *HTTPHost
NewHTTPHost returns an empty host whose client never follows a redirect.