Documentation
¶
Overview ¶
Package mockserver provides a configurable HTTP mock server for functional testing. It is designed to run as a test service, started by the test runner before test execution and stopped afterward. Routes are defined declaratively in solution YAML via the TestConfig.Services field.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EchoResponse ¶
type EchoResponse struct {
Method string `json:"method"`
Path string `json:"path"`
Headers map[string]string `json:"headers"`
Body string `json:"body"`
Query map[string]string `json:"query"`
}
EchoResponse is the JSON body returned when Echo is true.
type Request ¶
type Request struct {
Method string `json:"method"`
Path string `json:"path"`
Headers map[string]string `json:"headers"`
Body string `json:"body"`
Time time.Time `json:"time"`
}
Request records a received HTTP request for later inspection.
type Route ¶
type Route struct {
// Path is the URL path to match (exact match).
Path string `json:"path" yaml:"path" doc:"URL path to match (exact)" maxLength:"500"`
// Method is the HTTP method to match. Empty matches all methods.
Method string `json:"method,omitempty" yaml:"method,omitempty" doc:"HTTP method to match (empty = all)" maxLength:"10"`
// BodyContains is an optional substring that must appear in the request body
// for the route to match. Useful for routing POST endpoints like GraphQL where
// all requests hit the same path but carry different query payloads.
BodyContains string `json:"bodyContains,omitempty" yaml:"bodyContains,omitempty" doc:"Request body must contain this substring" maxLength:"1000"`
// Status is the HTTP status code to return (default: 200).
Status int `json:"status,omitempty" yaml:"status,omitempty" doc:"HTTP status code to return" maximum:"599"`
// Body is the response body string.
Body string `json:"body,omitempty" yaml:"body,omitempty" doc:"Response body" maxLength:"100000"`
// Headers are response headers to set.
Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty" doc:"Response headers"`
// Delay is the simulated response delay as a Go duration string (e.g., "100ms").
Delay string `json:"delay,omitempty" yaml:"delay,omitempty" doc:"Simulated response delay" maxLength:"20"`
// Echo when true returns the request details as JSON instead of Body.
Echo bool `json:"echo,omitempty" yaml:"echo,omitempty" doc:"Return request details as JSON"`
}
Route defines a single mock HTTP endpoint.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a configurable HTTP mock server for testing.
func (*Server) BaseURL ¶
BaseURL returns the base URL for the server (e.g., "http://127.0.0.1:12345").
Click to show internal directories.
Click to hide internal directories.