Documentation ¶
Index ¶
- type FailedPredicateError
- type Predicate
- func Bool(expected ...bool) Predicate
- func Float(expected ...float64) Predicate
- func Int(expected ...int64) Predicate
- func Map(expected ...map[string]interface{}) Predicate
- func Pattern(regex string) Predicate
- func Regex(regex *regexp.Regexp) Predicate
- func Slice(expected ...[]interface{}) Predicate
- func String(expected ...string) Predicate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FailedPredicateError ¶ added in v0.0.9
type FailedPredicateError struct { // The underlying error. Cause error // Stack of JSON field names that lead to the current expectation. FieldStack []string }
A FailedPredicateError indicates that a predicate failed.
func CompareValues ¶
func CompareValues(expected, actual interface{}, exactJSON bool) []*FailedPredicateError
CompareValues compares an expected value to an actual value.
func (*FailedPredicateError) Error ¶ added in v0.0.9
func (e *FailedPredicateError) Error() string
func (*FailedPredicateError) FieldString ¶ added in v0.0.9
func (e *FailedPredicateError) FieldString() string
FieldString returns a dot-delimited string representation of the field stack.
func (*FailedPredicateError) PushField ¶ added in v0.0.9
func (e *FailedPredicateError) PushField(field string)
PushField pushes a field name onto the field stack.
func (*FailedPredicateError) Unwrap ¶ added in v0.0.9
func (e *FailedPredicateError) Unwrap() error
type Predicate ¶
type Predicate func(interface{}) error
A Predicate is a function that takes a test result value and possibly returns an error.
func Bool ¶
Bool creates a predicate requiring a value to be a bool, optionally matching against a set of values.
func Float ¶ added in v0.0.9
Float creates a predicate requiring a value to be an floating point number, optionally matching against a set of values.
func Int ¶ added in v0.0.9
Int creates a predicate requiring a value to be an integer, optionally matching against a set of values.
func Map ¶
Map creates a predicate requiring a value to be a map, optionally matching against a set of values.
func Pattern ¶ added in v0.0.9
Pattern creates a predicate requiring a value to be a string that matches a regular expression, optionally matching against a set of values.
func Regex ¶ added in v0.0.9
Regex creates a predicate requiring a value to be a string that matches a regular expression, optionally matching against a set of values.
func Slice ¶
func Slice(expected ...[]interface{}) Predicate
Slice creates a predicate requiring a value to be a slice, optionally matching against a set of values.
func String ¶
String creates a predicate requiring a value to be a string, optionally matching against a set of values.
func (Predicate) And ¶ added in v0.0.9
And chains a new Predicate to run after the current Predicate if the current Predicate succeeds.