Documentation
¶
Overview ¶
Package localapptest is a fake of the HEY app's door for tests: a Unix socket that answers MCP as the door's contract does, from what a test gives it.
Index ¶
- func Listen(t testing.TB) (string, *net.UnixListener)
- type Door
- func (d *Door) Answer(name string, structured any)
- func (d *Door) AnswerRaw(name string, result map[string]any)
- func (d *Door) Calls() []json.RawMessage
- func (d *Door) Fail(method string, code int, message string)
- func (d *Door) Hang(method string)
- func (d *Door) Offer(name, description, effect string, arguments ...string)
- func (d *Door) Refuse(name string, structured any)
- func (d *Door) Reply(method, line string)
- func (d *Door) Requests() []Request
- type RPCError
- type Request
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Listen ¶
func Listen(t testing.TB) (string, *net.UnixListener)
Listen opens a Unix socket for a test that answers by hand, closed when the test ends. Its folder is short-named under the system's temporary folder, since a socket's path is capped near a hundred bytes and a test's own temporary folder on macOS is longer.
Types ¶
type Door ¶
type Door struct {
Path string
// contains filtered or unexported fields
}
Door answers initialize, tools/list and tools/call. A test offers tools (Offer) and sets what a call answers (Answer, Refuse, AnswerRaw), and may make a method answer with a JSON-RPC error (Fail), with a line of its own (Reply) or not at all (Hang), to see what a client makes of an app that misbehaves.
func (*Door) AnswerRaw ¶
AnswerRaw makes a tools/call of name answer with result, as written, for a result that is not what Answer builds.
func (*Door) Calls ¶
func (d *Door) Calls() []json.RawMessage
Calls is the params of every tools/call the door read.
func (*Door) Offer ¶
Offer lists a tool, with the effect the door names in its _meta and the arguments its schema declares, each required, as the door's are.
type Request ¶
type Request struct {
Method string
Params json.RawMessage
}
Request is one message the door read: its method and its params.