Documentation ¶
Index ¶
- Variables
- func ContextWithData(ctx context.Context, data map[string]interface{}) context.Context
- func ContextWithDataID(ctx context.Context, id string, val interface{}) error
- func ContextWithOptionalDataID(ctx context.Context, id string, val interface{}) error
- func DataFromContext(ctx context.Context) map[string]interface{}
- func DataIDFromContext(ctx context.Context, id string) interface{}
- type BodyCustomChecker
- type BodyCustomCheckerFunc
- type BodyEqualChecker
- type BodyJSONChecker
- type BodyJSONQueryEqualChecker
- type BodyJSONQueryExistsChecker
- type BodyJSONQueryRegexMatchChecker
- type Checker
- type DataEqualChecker
- type JSONQueryValueMissingError
- type StatusCodeEqualChecker
- type UnexpectedDataValueError
- type UnexpectedJSONBodyError
- type UnexpectedJSONQueryRegexValueError
- type UnexpectedJSONQueryValueError
- type UnexpectedStatusCode
- type UnexpectedValueError
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMissingCheckFunc is returned when a BodyCustomChecker is checked without a valid func. ErrMissingCheckFunc = errors.New("missing check func") )
Functions ¶
func ContextWithData ¶
ContextWithData embeds the given data in the context.
func ContextWithDataID ¶
ContextWithDataID embeds the given data item in the context.
func ContextWithOptionalDataID ¶
ContextWithDataID embeds the given data item in the context, if the ID is not empty.
func DataFromContext ¶
DataFromContext returns a map of check data from the context.
func DataIDFromContext ¶
DataIDFromContext returns data with the given ID from the context.
Types ¶
type BodyCustomChecker ¶
type BodyCustomChecker struct {
CheckBody BodyCustomCheckerFunc
}
BodyCustomChecker is used to run a BodyCustomCheckerFunc against the body bytes in the http response
type BodyCustomCheckerFunc ¶
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`
type BodyJSONChecker ¶
type BodyJSONChecker struct {
Value interface{}
}
BodyJSONChecker is used to validate http response body can be JSON decoded and is equal to `Value`
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`
type BodyJSONQueryExistsChecker ¶
BodyJSONQueryExistsChecker queries the http response body JSON using `Query` and ensures a value exists there
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`
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
type JSONQueryValueMissingError ¶
type JSONQueryValueMissingError struct { // Query is the JSON query. Query string }
JSONQueryValueMissingError is returned when a check fails.
func (*JSONQueryValueMissingError) Error ¶
func (e *JSONQueryValueMissingError) Error() string
Error returns an error string.
type StatusCodeEqualChecker ¶
type StatusCodeEqualChecker struct {
Value int
}
StatusCodeEqualChecker is used to validate the status code in the response
type UnexpectedDataValueError ¶
type UnexpectedDataValueError struct { // DataID is the ID of the data. DataID string // Expected is the expected value. Expected interface{} // Actual is the actual value. Actual interface{} }
UnexpectedDataValueError is returned when a check fails.
func (*UnexpectedDataValueError) Error ¶
func (e *UnexpectedDataValueError) Error() string
Error returns an error string.
type UnexpectedJSONBodyError ¶
type UnexpectedJSONBodyError struct { // Expected is the expected value. Expected interface{} // Actual is the actual value. Actual interface{} }
UnexpectedJSONBodyError is returned when a check fails.
func (*UnexpectedJSONBodyError) Error ¶
func (e *UnexpectedJSONBodyError) Error() string
Error returns an error string.
type UnexpectedJSONQueryRegexValueError ¶
type UnexpectedJSONQueryRegexValueError struct { // Pattern is the regex pattern. Pattern string // Query is the JSON query. Query string // Actual is the actual value. Actual string }
UnexpectedJSONQueryRegexValueError is returned when a check fails.
func (*UnexpectedJSONQueryRegexValueError) Error ¶
func (e *UnexpectedJSONQueryRegexValueError) Error() string
Error returns an error string.
type UnexpectedJSONQueryValueError ¶
type UnexpectedJSONQueryValueError struct { // Query is the JSON query. Query string // Expected is the expected value. Expected interface{} // Actual is the actual value. Actual interface{} }
UnexpectedJSONQueryValueError is returned when a check fails.
func (*UnexpectedJSONQueryValueError) Error ¶
func (e *UnexpectedJSONQueryValueError) Error() string
Error returns an error string.
type UnexpectedStatusCode ¶
type UnexpectedStatusCode struct { // Expected is the expected status code. Expected int // Actual is the actual status code. Actual int }
UnexpectedStatusCode is returned when a check fails.
func (*UnexpectedStatusCode) Error ¶
func (e *UnexpectedStatusCode) Error() string
Error returns an error string.
type UnexpectedValueError ¶
type UnexpectedValueError struct { // Expected is the expected value. Expected string // Actual is the actual value. Actual string }
UnexpectedValueError is returned when a check fails.
func (*UnexpectedValueError) Error ¶
func (e *UnexpectedValueError) Error() string
Error returns an error string.