internal

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// got a request that isn't matched by any matcher
	StatusUnexpectedRequest = 600
	// couldn't clone the request body
	StatusErrorCloningRequestBody = 601
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ExpectedRequest

type ExpectedRequest struct {
	Matcher RequestMatcher
	Handler http.Handler
}

ExpectedRequest is a request and response for your test

type RequestHandler

type RequestHandler struct {
	// contains filtered or unexported fields
}

RequestHandler is a handler that will serve responses for expected requests

func (*RequestHandler) Count

func (r *RequestHandler) Count() int

Count returns the number of requests the handler has served

func (*RequestHandler) Expect

func (r *RequestHandler) Expect(expectedRequest *ExpectedRequest)

Expect adds an expected request to the handler

func (*RequestHandler) ServeHTTP

func (r *RequestHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

type RequestMatcher

type RequestMatcher interface {
	Match(req *http.Request, requestCount int) bool
}

RequestMatcher matches requests with responses

func MatchAll

func MatchAll(matcher ...RequestMatcher) RequestMatcher

MatchAll matches when all matchers match the request

func MatchBody

func MatchBody(wantBody string) RequestMatcher

MatchBody matches when the request's body is equal to wantBody

func MatchRequestPath

func MatchRequestPath(wantPath string) RequestMatcher

MatchRequestPath matches when the request's URL path equals wantPath

func MatchRequestQuery

func MatchRequestQuery(wantQuery string) RequestMatcher

MatchRequestQuery matches when the request's URL query matches wantQuery

Jump to

Keyboard shortcuts

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