verify

package
v2.0.0-beta.2+incompat... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2015 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package verify provides support for using martian modifiers for request and response verifications.

Index

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 NewMultiError

func NewMultiError() *MultiError

NewMultiError returns a new MultiError.

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

type TestVerifier struct {
	RequestError  error
	ResponseError error
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL