Documentation ¶
Overview ¶
Package martiantest provides helper utilities for testing modifiers.
Index ¶
- type Matcher
- 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 Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher is a stubbed matcher used in tests.
func NewMatcher ¶
func NewMatcher() *Matcher
NewMatcher returns a pointer to martiantest.Matcher with the return values for MatchRequest and MatchResponse intiailized to true.
func (*Matcher) MatchRequest ¶
MatchRequest returns the stubbed value in tm.reqval.
func (*Matcher) MatchResponse ¶
MatchResponse returns the stubbed value in tm.resval.
func (*Matcher) RequestEvaluatesTo ¶
RequestEvaluatesTo sets the value returned by MatchRequest.
func (*Matcher) ResponseEvaluatesTo ¶
ResponseEvaluatesTo sets the value returned by MatchResponse.
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.