testkit

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ALBTargetGroupRequest added in v0.2.0

func ALBTargetGroupRequest(method, path string, opts HTTPEventOptions) events.ALBTargetGroupRequest

func APIGatewayV2Request

func APIGatewayV2Request(method, path string, opts HTTPEventOptions) events.APIGatewayV2HTTPRequest

func DynamoDBStreamEvent added in v0.2.0

func DynamoDBStreamEvent(opts DynamoDBStreamEventOptions) events.DynamoDBEvent

func EventBridgeEvent added in v0.2.0

func EventBridgeEvent(opts EventBridgeEventOptions) events.EventBridgeEvent

func KinesisEvent added in v0.2.0

func KinesisEvent(opts KinesisEventOptions) events.KinesisEvent

func LambdaFunctionURLRequest

func LambdaFunctionURLRequest(method, path string, opts HTTPEventOptions) events.LambdaFunctionURLRequest

func SNSEvent added in v0.2.0

func SNSEvent(opts SNSEventOptions) events.SNSEvent

func SQSEvent added in v0.2.0

func SQSEvent(opts SQSEventOptions) events.SQSEvent

func StepFunctionsTaskTokenEvent added in v0.2.0

func StepFunctionsTaskTokenEvent(opts StepFunctionsTaskTokenEventOptions) map[string]any

func WebSocketEvent added in v0.2.0

Types

type DynamoDBStreamEventOptions added in v0.2.0

type DynamoDBStreamEventOptions struct {
	StreamARN string
	Records   []DynamoDBStreamRecordOptions
}

type DynamoDBStreamRecordOptions added in v0.2.0

type DynamoDBStreamRecordOptions struct {
	EventID   string
	EventName string
}

type Env

type Env struct {
	Clock *ManualClock
	IDs   *ManualIDGenerator
}

Env is a deterministic local test environment for AppTheory apps.

func New

func New() *Env

func NewWithTime

func NewWithTime(now time.Time) *Env

func (*Env) App

func (e *Env) App(opts ...apptheory.Option) *apptheory.App

func (*Env) Invoke

func (e *Env) Invoke(ctx context.Context, app *apptheory.App, req apptheory.Request) apptheory.Response

func (*Env) InvokeALB added in v0.2.0

func (*Env) InvokeAPIGatewayV2

func (e *Env) InvokeAPIGatewayV2(
	ctx context.Context,
	app *apptheory.App,
	event events.APIGatewayV2HTTPRequest,
) events.APIGatewayV2HTTPResponse

func (*Env) InvokeDynamoDBStream added in v0.2.0

func (e *Env) InvokeDynamoDBStream(
	ctx context.Context,
	app *apptheory.App,
	event events.DynamoDBEvent,
) events.DynamoDBEventResponse

func (*Env) InvokeEventBridge added in v0.2.0

func (e *Env) InvokeEventBridge(
	ctx context.Context,
	app *apptheory.App,
	event events.EventBridgeEvent,
) (any, error)

func (*Env) InvokeKinesis added in v0.2.0

func (e *Env) InvokeKinesis(
	ctx context.Context,
	app *apptheory.App,
	event events.KinesisEvent,
) events.KinesisEventResponse

func (*Env) InvokeLambdaFunctionURL

func (e *Env) InvokeLambdaFunctionURL(
	ctx context.Context,
	app *apptheory.App,
	event events.LambdaFunctionURLRequest,
) events.LambdaFunctionURLResponse

func (*Env) InvokeSNS added in v0.2.0

func (e *Env) InvokeSNS(ctx context.Context, app *apptheory.App, event events.SNSEvent) ([]any, error)

func (*Env) InvokeSQS added in v0.2.0

func (e *Env) InvokeSQS(ctx context.Context, app *apptheory.App, event events.SQSEvent) events.SQSEventResponse

func (*Env) InvokeStreaming added in v0.2.0

func (e *Env) InvokeStreaming(ctx context.Context, app *apptheory.App, req apptheory.Request) StreamResult

InvokeStreaming executes an AppTheory request and captures streamed response chunks deterministically.

Headers and cookies are captured before reading the first chunk so tests can assert header finalization.

func (*Env) InvokeWebSocket added in v0.2.0

type EventBridgeEventOptions added in v0.2.0

type EventBridgeEventOptions struct {
	ID         string
	Source     string
	DetailType string
	Resources  []string
	Detail     any
	Time       time.Time
	Region     string
	AccountID  string
}

type FakeSNSClient added in v0.2.0

type FakeSNSClient struct {
	Calls []SNSPublishCall

	PublishErr error
	// contains filtered or unexported fields
}

func NewFakeSNSClient added in v0.2.0

func NewFakeSNSClient() *FakeSNSClient

func (*FakeSNSClient) Publish added in v0.2.0

func (f *FakeSNSClient) Publish(
	_ context.Context,
	params *sns.PublishInput,
	_ ...func(*sns.Options),
) (*sns.PublishOutput, error)

type FakeStreamerClient added in v0.2.0

type FakeStreamerClient struct {
	Endpoint string
	Calls    []StreamerCall

	Connections map[string]streamer.Connection

	PostErr   error
	GetErr    error
	DeleteErr error
	// contains filtered or unexported fields
}

func NewFakeStreamerClient added in v0.2.0

func NewFakeStreamerClient(endpoint string) *FakeStreamerClient

func (*FakeStreamerClient) DeleteConnection added in v0.2.0

func (f *FakeStreamerClient) DeleteConnection(_ context.Context, connectionID string) error

func (*FakeStreamerClient) GetConnection added in v0.2.0

func (f *FakeStreamerClient) GetConnection(_ context.Context, connectionID string) (streamer.Connection, error)

func (*FakeStreamerClient) PostToConnection added in v0.2.0

func (f *FakeStreamerClient) PostToConnection(_ context.Context, connectionID string, data []byte) error

type HTTPEventOptions

type HTTPEventOptions struct {
	Query        map[string][]string
	Headers      map[string]string
	MultiHeaders map[string][]string
	Cookies      []string
	Body         []byte
	IsBase64     bool
}

HTTPEventOptions configures synthetic HTTP events for local testing.

type KinesisEventOptions added in v0.2.0

type KinesisEventOptions struct {
	StreamARN string
	Records   []KinesisRecordOptions
}

type KinesisRecordOptions added in v0.2.0

type KinesisRecordOptions struct {
	EventID        string
	EventSourceARN string
	PartitionKey   string
	Data           []byte
}

type ManualClock

type ManualClock struct {
	// contains filtered or unexported fields
}

ManualClock is a deterministic, mutable clock for tests.

func NewManualClock

func NewManualClock(now time.Time) *ManualClock

func (*ManualClock) Advance

func (c *ManualClock) Advance(d time.Duration) time.Time

func (*ManualClock) Now

func (c *ManualClock) Now() time.Time

func (*ManualClock) Set

func (c *ManualClock) Set(now time.Time)

type ManualIDGenerator

type ManualIDGenerator struct {
	// contains filtered or unexported fields
}

ManualIDGenerator is a deterministic, predictable ID generator for tests.

func NewManualIDGenerator

func NewManualIDGenerator() *ManualIDGenerator

func (*ManualIDGenerator) NewID

func (g *ManualIDGenerator) NewID() string

func (*ManualIDGenerator) Queue

func (g *ManualIDGenerator) Queue(ids ...string)

func (*ManualIDGenerator) Reset

func (g *ManualIDGenerator) Reset()

type SNSEventOptions added in v0.2.0

type SNSEventOptions struct {
	TopicARN string
	Records  []SNSRecordOptions
}

type SNSPublishCall added in v0.2.0

type SNSPublishCall struct {
	TopicARN string
	Subject  string
	Message  string
}

type SNSRecordOptions added in v0.2.0

type SNSRecordOptions struct {
	MessageID string
	TopicArn  string
	Subject   string
	Message   string
}

type SQSEventOptions added in v0.2.0

type SQSEventOptions struct {
	QueueARN string
	Records  []SQSMessageOptions
}

type SQSMessageOptions added in v0.2.0

type SQSMessageOptions struct {
	MessageID         string
	Body              string
	EventSourceARN    string
	MessageAttributes map[string]events.SQSMessageAttribute
}

type StepFunctionsTaskTokenEventOptions added in v0.2.0

type StepFunctionsTaskTokenEventOptions struct {
	TaskToken string
	Payload   map[string]any
}

type StreamResult added in v0.2.0

type StreamResult struct {
	Status          int
	Headers         map[string][]string
	Cookies         []string
	Chunks          [][]byte
	Body            []byte
	IsBase64        bool
	StreamErrorCode string
}

StreamResult captures a streamed AppTheory response deterministically for tests.

type StreamerCall added in v0.2.0

type StreamerCall struct {
	Op           string
	ConnectionID string
	Data         []byte
}

type WebSocketEventOptions added in v0.2.0

type WebSocketEventOptions struct {
	RouteKey     string
	EventType    string
	ConnectionID string
	DomainName   string
	Stage        string
	RequestID    string
	Body         string
	IsBase64     bool

	Headers               map[string]string
	MultiValueHeaders     map[string][]string
	QueryStringParameters map[string]string
	MultiValueQueryString map[string][]string
}

Directories

Path Synopsis
Package mcp provides deterministic MCP client simulation and assertion helpers for testing MCP tool implementations without deploying infrastructure.
Package mcp provides deterministic MCP client simulation and assertion helpers for testing MCP tool implementations without deploying infrastructure.
Package oauth provides a small test harness for OAuth flows used by Claude Remote MCP connectors (DCR + PKCE + refresh).
Package oauth provides a small test harness for OAuth flows used by Claude Remote MCP connectors (DCR + PKCE + refresh).

Jump to

Keyboard shortcuts

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