Documentation ¶
Overview ¶
Package verify provides support for using martian modifiers for request and response verifications.
Index ¶
- type Handler
- type MultiError
- type RequestResponseVerifier
- type RequestVerifier
- type ResetHandler
- type ResponseVerifier
- type TestVerifier
- func (tv *TestVerifier) ModifyRequest(*http.Request) error
- func (tv *TestVerifier) ModifyResponse(*http.Response) error
- func (tv *TestVerifier) ResetRequestVerifications()
- func (tv *TestVerifier) ResetResponseVerifications()
- func (tv *TestVerifier) VerifyRequests() error
- func (tv *TestVerifier) VerifyResponses() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is an http.Handler that returns the request and response verifications of reqv and resv as JSON.
func NewHandler ¶
func NewHandler() *Handler
NewHandler returns an http.Handler for requesting the verification error status.
func (*Handler) ServeHTTP ¶
func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
ServeHTTP writes out a JSON response containing a list of verification errors that occurred during the requests and responses sent to the proxy.
func (*Handler) SetRequestVerifier ¶
func (h *Handler) SetRequestVerifier(reqv RequestVerifier)
SetRequestVerifier sets the RequestVerifier to verify.
func (*Handler) SetResponseVerifier ¶
func (h *Handler) SetResponseVerifier(resv ResponseVerifier)
SetResponseVerifier sets the ResponseVerifier to verify.
type MultiError ¶
type MultiError struct {
// contains filtered or unexported fields
}
MultiError is a collection of errors that implements the error interface.
func (*MultiError) Add ¶
func (merr *MultiError) Add(err error)
Add appends an error to the error collection.
func (*MultiError) Empty ¶
func (merr *MultiError) Empty() bool
Empty returns whether the *MultiError contains any errors.
func (*MultiError) Error ¶
func (merr *MultiError) Error() string
Error returns the list of errors separated by newlines.
func (*MultiError) Errors ¶
func (merr *MultiError) Errors() []error
Errors returns the error slice containing the error collection.
type RequestResponseVerifier ¶
type RequestResponseVerifier interface { RequestVerifier ResponseVerifier }
RequestResponseVerifier is a RequestVerifier and a ResponseVerifier.
type RequestVerifier ¶
type RequestVerifier interface { martian.RequestModifier VerifyRequests() error ResetRequestVerifications() }
RequestVerifier is a RequestModifier that maintains a verification state. RequestVerifiers should only return an error from ModifyRequest for errors unrelated to the expectation.
type ResetHandler ¶
type ResetHandler struct {
// contains filtered or unexported fields
}
ResetHandler is an http.Handler that resets the request and response verifications of reqv and resv.
func NewResetHandler ¶
func NewResetHandler() *ResetHandler
NewResetHandler returns an http.Handler for reseting the verification error status.
func (*ResetHandler) ServeHTTP ¶
func (h *ResetHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
ServeHTTP resets the verifier for the given ID so that it may be run again.
func (*ResetHandler) SetRequestVerifier ¶
func (h *ResetHandler) SetRequestVerifier(reqv RequestVerifier)
SetRequestVerifier sets the RequestVerifier to reset.
func (*ResetHandler) SetResponseVerifier ¶
func (h *ResetHandler) SetResponseVerifier(resv ResponseVerifier)
SetResponseVerifier sets the ResponseVerifier to reset.
type ResponseVerifier ¶
type ResponseVerifier interface { martian.ResponseModifier VerifyResponses() error ResetResponseVerifications() }
ResponseVerifier is a ResponseModifier that maintains a verification state. ResponseVerifiers should only return an error from ModifyResponse for errors unrelated to the expectation.
type TestVerifier ¶
TestVerifier is a request and response verifier with overridable errors for verification.
func (*TestVerifier) ModifyRequest ¶
func (tv *TestVerifier) ModifyRequest(*http.Request) error
ModifyRequest is a no-op.
func (*TestVerifier) ModifyResponse ¶
func (tv *TestVerifier) ModifyResponse(*http.Response) error
ModifyResponse is a no-op.
func (*TestVerifier) ResetRequestVerifications ¶
func (tv *TestVerifier) ResetRequestVerifications()
ResetRequestVerifications clears out the set request error.
func (*TestVerifier) ResetResponseVerifications ¶
func (tv *TestVerifier) ResetResponseVerifications()
ResetResponseVerifications clears out the set response error.
func (*TestVerifier) VerifyRequests ¶
func (tv *TestVerifier) VerifyRequests() error
VerifyRequests returns the set request error.
func (*TestVerifier) VerifyResponses ¶
func (tv *TestVerifier) VerifyResponses() error
VerifyResponses returns the set response error.