check

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithData

func ContextWithData(ctx context.Context, data map[string]interface{}) context.Context

func ContextWithDataID

func ContextWithDataID(ctx context.Context, id string, val interface{}) error

func ContextWithOptionalDataID

func ContextWithOptionalDataID(ctx context.Context, id string, val interface{}) error

func DataFromContext

func DataFromContext(ctx context.Context) map[string]interface{}

func DataIDFromContext

func DataIDFromContext(ctx context.Context, id string) interface{}

Types

type BodyCustomChecker

type BodyCustomChecker struct {
	CheckBody BodyCustomCheckerFunc
}

BodyCustomChecker is used to run a BodyCustomCheckerFunc against the body bytes in the http response

func (*BodyCustomChecker) Check

func (c *BodyCustomChecker) Check(ctx context.Context, response *http.Response) error

Check performs the BodyCustom check

type BodyCustomCheckerFunc

type BodyCustomCheckerFunc func([]byte) error

BodyCustomCheckerFunc defines the function used to perform a custom http response body check

type BodyEqualChecker

type BodyEqualChecker struct {
	Value string
}

BodyEqualChecker is used to validate the http response body string exactly matches `Value`

func (*BodyEqualChecker) Check

func (c *BodyEqualChecker) Check(ctx context.Context, response *http.Response) error

Check performs the BodyEqual check

type BodyJSONChecker

type BodyJSONChecker struct {
	Value interface{}
}

BodyJSONChecker is used to validate http response body can be JSON decoded and is equal to `Value`

func (*BodyJSONChecker) Check

func (c *BodyJSONChecker) Check(ctx context.Context, response *http.Response) error

Check performs the BodyJSON check

type BodyJSONQueryEqualChecker

type BodyJSONQueryEqualChecker struct {
	Query     string
	Value     interface{}
	NullValue bool
	DataID    string
}

BodyJSONQueryEqualChecker queries the http response body JSON using `Query` and ensures the value is equal to `Value`

func (*BodyJSONQueryEqualChecker) Check

func (c *BodyJSONQueryEqualChecker) Check(ctx context.Context, response *http.Response) error

Check performs the BodyJSONQueryEqual check

type BodyJSONQueryExistsChecker

type BodyJSONQueryExistsChecker struct {
	Query  string
	DataID string
}

BodyJSONQueryExistsChecker queries the http response body JSON using `Query` and ensures a value exists there

func (*BodyJSONQueryExistsChecker) Check

func (c *BodyJSONQueryExistsChecker) Check(ctx context.Context, response *http.Response) error

Check performs the BodyJSONQueryExists check

type BodyJSONQueryRegexMatchChecker

type BodyJSONQueryRegexMatchChecker struct {
	Query   string
	Regexp  *regexp.Regexp
	DataIDs map[int]string
}

BodyJSONQueryRegexMatchChecker queries the http response body JSON using `Query` and ensures that it matches the regex pattern in `Regexp`

func (*BodyJSONQueryRegexMatchChecker) Check

Check performs the BodyJSONQueryRegexMatch check

type Checker

type Checker interface {
	Check(ctx context.Context, response *http.Response) error
}

Checker is used to outline each individual response check

type DataEqualChecker

type DataEqualChecker struct {
	DataID string
	Value  interface{}
}

DataEqualChecker is used to check whether or not the value stored in the context data is equal to the given value

func (*DataEqualChecker) Check

func (c *DataEqualChecker) Check(ctx context.Context, response *http.Response) error

Check performs the DataEqual check

type StatusCodeEqualChecker

type StatusCodeEqualChecker struct {
	Value int
}

StatusCodeEqualChecker is used to validate the status code in the response

func (*StatusCodeEqualChecker) Check

func (c *StatusCodeEqualChecker) Check(ctx context.Context, response *http.Response) error

Check performs the StatusCodeEqual check

Jump to

Keyboard shortcuts

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