Documentation
¶
Overview ¶
Package toolkittest is the conformance kit a tool runs from its own tests:
func TestConformance(t *testing.T) {
toolkittest.Run(t, toolkittest.Suite{
New: func(t testing.TB) toolkittest.Fixture {
reg, store := newRegistry()
return toolkittest.Fixture{Registry: reg, State: store.Snapshot}
},
Options: options(),
Cases: map[string]toolkittest.Case{
"note.delete": {Input: map[string]any{"id": "n1"}, Args: []string{"note", "n1", "delete"}},
},
})
}
It checks that the metadata is schema-valid, that MCP tools/list and the OpenAPI document match the registry, that every surface returns the same output for the same input, that destructive operations refuse to apply without confirm on the CLI, HTTP and MCP, and that writes only preview without apply. All calls are in-process, with no network or credentials.
Index ¶
- func CheckMCPTools(t testing.TB, reg *op.Registry, tools []*sdk.Tool)
- func CheckMetadata(t testing.TB, doc []byte)
- func CheckOpenAPI(t testing.TB, reg *op.Registry, doc []byte)
- func ErrorCode(body []byte) string
- func MCPClient(t testing.TB, reg *op.Registry, auth op.Authorizer) *sdk.ClientSession
- func Run(t *testing.T, s Suite)
- func SameJSON(a, b []byte) bool
- type Case
- type Fixture
- type Suite
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckMCPTools ¶
CheckMCPTools checks that tools, from any MCP transport, are exactly the registry's MCP operations, with the registry's input schemas and effect annotations.
func CheckMetadata ¶
CheckMetadata validates a metadata document against toolkit.metadata.v1.
func CheckOpenAPI ¶
CheckOpenAPI checks that an OpenAPI document has exactly one POST path per operation, with the registry's input and output schemas and effect.
func MCPClient ¶
func MCPClient(t testing.TB, reg *op.Registry, auth op.Authorizer) *sdk.ClientSession
MCPClient connects an in-memory MCP client to reg's tools. A nil auth means op.DenyWrites, the served default.
Types ¶
type Case ¶
type Case struct {
// Input is the wire input without apply and confirm.
Input map[string]any
// Args select the same call on the CLI, without --apply, --yes or --json.
Args []string
}
Case is one call of an operation, expressed for every surface.
type Fixture ¶
type Fixture struct {
Registry *op.Registry
// State returns a JSON-encodable snapshot of the backend. The kit compares
// snapshots to prove that previews and refused calls change nothing, and
// that an applied call does change something.
State func() any
}
Fixture is one fresh registry over a fresh fake backend.
type Suite ¶
type Suite struct {
// New returns a fresh fixture. Each check gets its own.
New func(t testing.TB) Fixture
// Options are the tool's toolkit options. Authorizer is ignored: the kit
// tests the default and an allow-all authorizer explicitly.
Options toolkit.Options
// Cases maps operation names to a call. Every write and destructive
// operation needs one. A read case adds a parity check.
Cases map[string]Case
}
Suite describes a tool for Run.