testkit

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTestContentDir

func CreateTestContentDir(t testing.TB, opts *ContentDirOptions) string

CreateTestContentDir creates a temp content directory with metadata and optional resources. Returns the content directory path.

func DefaultMetadata

func DefaultMetadata() string

DefaultMetadata returns the default test metadata YAML

func GetFreePort

func GetFreePort() (int, error)

GetFreePort returns a free port from the kernel

func MustGetFreePort

func MustGetFreePort(t testing.TB) int

MustGetFreePort returns a free port or fails the test

func NewTestFlags

func NewTestFlags(t testing.TB, contentDir string, opts *FlagOptions) *pflag.FlagSet

NewTestFlags creates a configured pflag.FlagSet for testing

Types

type ContentDirOptions

type ContentDirOptions struct {
	Metadata  string            // Custom metadata YAML (uses default if empty)
	Resources map[string]string // filename -> content (no resources if nil)
	Prompts   map[string]string // filename -> content (no prompts if nil)
}

ContentDirOptions configures CreateTestContentDir

type FlagOptions

type FlagOptions struct {
	Port      int    // Uses free port if 0
	Transport string // Defaults to "sse"
	AuthType  string // Defaults to "none"
	Host      string // Defaults to "localhost"
	Scheme    string // Defaults to "" (uses config default "acdc")
}

FlagOptions configures NewTestFlags

type RunnerFunc

type RunnerFunc func(ctx context.Context, params app.RunParams, flags *pflag.FlagSet, version string) error

type Service

type Service interface {
	Start() (map[string]any, error)
	Stop() error
	GetName() string
}

func NewACDCService

func NewACDCService(name string, flags *pflag.FlagSet) Service

type TestClient added in v0.3.0

type TestClient struct {
	Session *mcp.ClientSession
	// contains filtered or unexported fields
}

TestClient wraps an MCP ClientSession for testing via stdio or SSE transport.

func NewSSETestClient added in v0.3.0

func NewSSETestClient(t testing.TB, contentOpts *ContentDirOptions) *TestClient

NewSSETestClient creates a test client connected to an ACDC server via SSE transport. It starts the server, creates an MCP client, and connects via SSE.

func NewStdioTestClient added in v0.3.0

func NewStdioTestClient(t testing.TB, contentOpts *ContentDirOptions) *TestClient

NewStdioTestClient creates a test client connected to an ACDC server via stdio transport. It starts the server, creates an MCP client, and connects them via pipes.

func (*TestClient) CallTool added in v0.3.0

func (tc *TestClient) CallTool(ctx context.Context, name string, args map[string]any) (*mcp.CallToolResult, error)

CallTool calls a tool by name with the given arguments

func (*TestClient) Close added in v0.3.0

func (tc *TestClient) Close()

Close stops the client and server

func (*TestClient) GetPrompt added in v0.3.0

func (tc *TestClient) GetPrompt(ctx context.Context, name string, args map[string]string) (*mcp.GetPromptResult, error)

GetPrompt gets a prompt by name with arguments

func (*TestClient) InitializeResult added in v0.3.0

func (tc *TestClient) InitializeResult() *mcp.InitializeResult

InitializeResult returns the server's initialize response

func (*TestClient) ListPrompts added in v0.3.0

func (tc *TestClient) ListPrompts(ctx context.Context) (*mcp.ListPromptsResult, error)

ListPrompts returns all prompts from the server

func (*TestClient) ListResources added in v0.3.0

func (tc *TestClient) ListResources(ctx context.Context) (*mcp.ListResourcesResult, error)

ListResources returns all resources from the server

func (*TestClient) ListTools added in v0.3.0

func (tc *TestClient) ListTools(ctx context.Context) (*mcp.ListToolsResult, error)

ListTools returns all tools from the server

func (*TestClient) ReadResource added in v0.3.0

func (tc *TestClient) ReadResource(ctx context.Context, uri string) (*mcp.ReadResourceResult, error)

ReadResource reads a resource by URI

type TestEnv

type TestEnv interface {
	Start() (map[string]any, error)
	Stop() error
	GetContext() TestEnvContext
}

func NewTestEnv

func NewTestEnv(services ...Service) TestEnv

type TestEnvContext

type TestEnvContext interface {
	GetProperties() map[string]any
	GetProperty(name string) (any, bool)
}

Jump to

Keyboard shortcuts

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