test

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsHeaderer

type AsHeaderer http.Header

func (AsHeaderer) Header

func (h AsHeaderer) Header() http.Header

type Case

type Case struct {
	// V is the value to be encode and written to the Responder
	V interface{}

	// R is the http.Request object
	R *http.Request

	// W is the expected values that should be written
	W ResponseWriter

	// Err is the expected error
	Err error

	// ErrComparator will be used if defined to compare the errors
	ErrComparator func(expected, got error) bool
}

Case is a test case for a responder

func (Case) Test

func (tc Case) Test(responder responders.Func) func(*testing.T)

type ResponseWriter

type ResponseWriter struct {

	// Status is the http status that should be set
	Status int

	// Headers that must exist and their values
	Headers http.Header

	// Body is the expected body
	Body io.Reader

	// StatusCodeComparator will be used to check the status code
	StatusCodeComparator func(expected, got int) bool

	// HeadersComparator will be used to check the headers
	HeaderComparator func(expected, got http.Header) bool

	// BodyComparator will be used to check the body
	BodyComparator func(expected, got []byte) bool
	// contains filtered or unexported fields
}

func (*ResponseWriter) CheckBody

func (mrw *ResponseWriter) CheckBody(t *testing.T) bool

func (*ResponseWriter) CheckHeaders

func (mrw *ResponseWriter) CheckHeaders(t *testing.T) bool

func (*ResponseWriter) CheckStatusCode

func (mrw *ResponseWriter) CheckStatusCode(t *testing.T) bool

func (*ResponseWriter) Header

func (mrw *ResponseWriter) Header() http.Header

func (*ResponseWriter) Write

func (mrw *ResponseWriter) Write(b []byte) (int, error)

func (*ResponseWriter) WriteHeader

func (mrw *ResponseWriter) WriteHeader(statusCode int)

Jump to

Keyboard shortcuts

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