Documentation ¶
Overview ¶
Package martiantest provides helper utilities for testing modifiers.
Index ¶
- type Modifier
- func (m *Modifier) ModifyRequest(req *http.Request) error
- func (m *Modifier) ModifyResponse(res *http.Response) error
- func (m *Modifier) RequestCount() int32
- func (m *Modifier) RequestError(err error)
- func (m *Modifier) RequestFunc(reqfunc func(req *http.Request))
- func (m *Modifier) RequestModified() bool
- func (m *Modifier) Reset()
- func (m *Modifier) ResponseCount() int32
- func (m *Modifier) ResponseError(err error)
- func (m *Modifier) ResponseFunc(resfunc func(res *http.Response))
- func (m *Modifier) ResponseModified() bool
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Modifier ¶
type Modifier struct {
// contains filtered or unexported fields
}
Modifier keeps track of the number of requests and responses it has modified and can be configured to return errors or run custom functions.
func (*Modifier) ModifyRequest ¶
ModifyRequest increases the count of requests seen and runs reqfunc if configured.
func (*Modifier) ModifyResponse ¶
ModifyResponse increases the count of responses seen and runs resfunc if configured.
func (*Modifier) RequestCount ¶
RequestCount returns the number of requests modified.
func (*Modifier) RequestError ¶
RequestError overrides the error returned by ModifyRequest.
func (*Modifier) RequestFunc ¶
RequestFunc is a function to run during ModifyRequest.
func (*Modifier) RequestModified ¶
RequestModified returns whether a request has been modified.
func (*Modifier) Reset ¶
func (m *Modifier) Reset()
Reset resets the request and response counts, the custom functions, and the modifier errors.
func (*Modifier) ResponseCount ¶
ResponseCount returns the number of responses modified.
func (*Modifier) ResponseError ¶
ResponseError overrides the error returned by ModifyResponse.
func (*Modifier) ResponseFunc ¶
ResponseFunc is a function to run during ModifyResponse.
func (*Modifier) ResponseModified ¶
ResponseModified returns whether a response has been modified.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is an http.RoundTripper for testing.
func NewTransport ¶
func NewTransport() *Transport
NewTransport builds a new transport that will respond with a 200 OK response.
func (*Transport) CopyHeaders ¶
CopyHeaders sets the transport to respond with a 200 OK response with headers copied from the request to the response verbatim.
func (*Transport) RespondError ¶
RespondError sets the transport to respond with an error on round trip.