Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultResponder responder = func(req *http.Request, reqm *RequestMatter, respms []*ResponseMatter) *ResponseMatter {
return respms[0]
}
DefaultResponder returns the first response without any assertions
View Source
var ErrCreatingMatter = newErrFn("failed to create matter")
View Source
var ErrExecutingTemplate = newErrFn("failed to execute template")
View Source
var ErrNotImplemented = newErrFn("not implemented")
View Source
var ErrOpeningFile = newErrFn("failed to open file")
View Source
var ErrParsingFile = newErrFn("failed to parse file")
View Source
var ErrParsingTemplate = newErrFn("failed to parse template")
View Source
var ErrReadingFile = newErrFn("failed to read file")
View Source
var RequestResponse = func(ca requester) responder { return func(req *http.Request, reqm *RequestMatter, respms []*ResponseMatter) *ResponseMatter { return respms[ca(req)] } }
RequestResponse returns a responder that asserts the request and returns the response at the index returned by the asserter
Functions ¶
Types ¶
type Matter ¶
type Matter struct {
Namespace string
Name string
Vars map[string]any
// contains filtered or unexported fields
}
Matter is a generic matter that can be used to store content and error
func (*Matter) WithOptions ¶
type Option ¶
func WithVariables ¶
type RequestMatter ¶
RequestMatter is a matter that can be used to store request content and error
func NewRequestMatter ¶
func NewRequestMatter(namespace, name string) *RequestMatter
func Request ¶
func Request(namespace, name string, opts ...Option) (*RequestMatter, error)
Request returns a http request with frontmatter for a given namespace and name
func (*RequestMatter) BodyBytes ¶
func (rm *RequestMatter) BodyBytes() ([]byte, error)
func (*RequestMatter) BodyString ¶
func (rm *RequestMatter) BodyString() (string, error)
func (*RequestMatter) Parse ¶
func (rm *RequestMatter) Parse() error
func (*RequestMatter) Save ¶ added in v0.1.3
func (rm *RequestMatter) Save() error
type ResponseMatter ¶
ResponseMatter is a matter that can be used to store response content and error
func NewResponseMatter ¶
func NewResponseMatter(namespace, name string) *ResponseMatter
func Response ¶
func Response(namespace, name string, opts ...Option) (*ResponseMatter, error)
Response returns a http response with frontmatter for a given namespace and name
func (*ResponseMatter) BodyBytes ¶
func (rm *ResponseMatter) BodyBytes() ([]byte, error)
func (*ResponseMatter) BodyString ¶
func (rm *ResponseMatter) BodyString() (string, error)
func (*ResponseMatter) Dump ¶ added in v0.1.3
func (rm *ResponseMatter) Dump(resp *http.Response) error
func (*ResponseMatter) Parse ¶
func (rm *ResponseMatter) Parse() error
func (*ResponseMatter) Save ¶ added in v0.1.3
func (rm *ResponseMatter) Save() error
Click to show internal directories.
Click to hide internal directories.