planner

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package planner provides functionalities for deciding what expectation matches the given request.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchBody

func MatchBody(expected *request.Request, actual *http.Request) (err error)

MatchBody matches the payload of a given request.

func MatchHeader

func MatchHeader(expected *request.Request, actual *http.Request) (err error)

MatchHeader matches the header of a given request.

func MatchMethod

func MatchMethod(expected *request.Request, actual *http.Request) (err error)

MatchMethod matches the method of a given request.

func MatchRequest

func MatchRequest(expected *request.Request, actual *http.Request) error

MatchRequest checks whether a request is matched.

func MatchURI

func MatchURI(expected *request.Request, actual *http.Request) (err error)

MatchURI matches the URI of a given request.

Types

type Error

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

Error represents an error that occurs while matching a request.

func NewError

func NewError(expected *request.Request, request *http.Request, messageFormat string, messageArgs ...interface{}) *Error

NewError creates a new Error.

func (Error) Error

func (e Error) Error() string

Error satisfies the error interface.

type Planner

type Planner interface {
	// IsEmpty checks whether the planner has no expectation.
	IsEmpty() bool
	// Expect adds a new expectation.
	Expect(expect *request.Request)
	// Plan decides how a request matches an expectation.
	Plan(req *http.Request) (*request.Request, error)
	// Remain returns remain expectations.
	Remain() []*request.Request
	// Reset removes all the expectations.
	Reset()
}

Planner or Request Execution Planner is in charge of selecting the right expectation for a given request.

func Sequence

func Sequence() Planner

Sequence creates a new Planner that matches the request sequentially.

Jump to

Keyboard shortcuts

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