localapptest

package
v1.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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 Start

func Start(t testing.TB) *Door

Start opens a door, closed when the test ends.

func (*Door) Answer

func (d *Door) Answer(name string, structured any)

Answer makes a tools/call of name answer structured, done.

func (*Door) AnswerRaw

func (d *Door) AnswerRaw(name string, result map[string]any)

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) Fail

func (d *Door) Fail(method string, code int, message string)

Fail makes method answer with a JSON-RPC error.

func (*Door) Hang

func (d *Door) Hang(method string)

Hang makes method go unanswered, the connection left open.

func (*Door) Offer

func (d *Door) Offer(name, description, effect string, arguments ...string)

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.

func (*Door) Refuse

func (d *Door) Refuse(name string, structured any)

Refuse makes a tools/call of name answer structured as a refusal (isError).

func (*Door) Reply

func (d *Door) Reply(method, line string)

Reply makes method answer with line, as written, in place of an answer.

func (*Door) Requests

func (d *Door) Requests() []Request

Requests is every message the door has read, notifications included, in order.

type RPCError

type RPCError struct {
	Code    int
	Message string
}

type Request

type Request struct {
	Method string
	Params json.RawMessage
}

Request is one message the door read: its method and its params.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL