Documentation
¶
Overview ¶
Package mock provides a configurable mock A2A server for use in tests.
It serves canned responses per skill with optional input matching, latency injection, and error injection.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type A2AServer ¶
type A2AServer struct {
// contains filtered or unexported fields
}
A2AServer is a lightweight mock A2A server backed by httptest.Server.
func NewA2AServer ¶
NewA2AServer creates a mock server with the given card and options. Call Start to begin serving.
type AgentConfig ¶
type AgentConfig struct {
Name string `json:"name" yaml:"name"`
Card a2a.AgentCard `json:"card" yaml:"card"`
Responses []RuleConfig `json:"responses" yaml:"responses"`
}
AgentConfig is the YAML-friendly configuration for a mock agent.
type MatchConfig ¶
type MatchConfig struct {
Contains string `json:"contains,omitempty" yaml:"contains,omitempty"`
Regex string `json:"regex,omitempty" yaml:"regex,omitempty"`
}
MatchConfig describes how to match incoming messages.
type Option ¶
type Option func(*A2AServer)
Option configures an A2AServer.
func OptionsFromConfig ¶
func OptionsFromConfig(cfg *AgentConfig) []Option
OptionsFromConfig converts an AgentConfig's response rules into Options.
func WithInputMatcher ¶
WithInputMatcher adds a rule that fires when the matcher returns true for the given skill ID. Rules are evaluated in order; first match wins.
func WithLatency ¶
WithLatency adds a delay before processing each message/send request.
func WithSkillError ¶
WithSkillError adds a rule that returns a failed task for the given skill ID.
func WithSkillResponse ¶
WithSkillResponse adds a rule that returns response for the given skill ID.
type PartConfig ¶
type PartConfig struct {
Text string `json:"text" yaml:"text"`
}
PartConfig describes a single response part.
type ResponseConfig ¶
type ResponseConfig struct {
Parts []PartConfig `json:"parts" yaml:"parts"`
}
ResponseConfig describes the response parts.
type RuleConfig ¶
type RuleConfig struct {
Skill string `json:"skill" yaml:"skill"`
Match *MatchConfig `json:"match,omitempty" yaml:"match,omitempty"`
Response *ResponseConfig `json:"response,omitempty" yaml:"response,omitempty"`
Error string `json:"error,omitempty" yaml:"error,omitempty"`
}
RuleConfig describes a single response rule.