Documentation
¶
Index ¶
- func AllKeys(expected ...interface{}) *gocrest.Matcher
- func EveryElement(expects ...*gocrest.Matcher) *gocrest.Matcher
- func FieldNamed(expected string) *gocrest.Matcher
- func FunctionNamed(expected string) *gocrest.Matcher
- func Key(expected interface{}) *gocrest.Matcher
- func Length(expected interface{}) *gocrest.Matcher
- func Prefix(expected string) *gocrest.Matcher
- func StructWithValues(expects StructMatchers) *gocrest.Matcher
- func Suffix(expected string) *gocrest.Matcher
- func TypeName(expected interface{}) *gocrest.Matcher
- type StructMatchers
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllKeys ¶
AllKeys is a matcher that checks if map actual has all keys == expecteds. Panics when actual's Kind is not a map. Returns a matcher that matches when a map has all keys == all expected.
func EveryElement ¶ added in v1.0.5
EveryElement Checks whether the nth element of the array/slice matches the nth expectation passed Panics if the actual is not an array/slice Panics if the count of the expectations does not match the array's/slice's length
func FieldNamed ¶
FieldNamed is a naive implementation for testing if a struct has a particular field name. Does not check type. Returns a matcher that will use reflect to check if the actual has the method given by expected
func FunctionNamed ¶
FunctionNamed implementation for testing if a Type has a particular method name. Does not check parameters. Returns a matcher that will use reflect to check if the actual has the method given by expected.
func Key ¶
Key is a matcher that checks if actual has a key == expected. Panics when actual's Kind is not a map. Returns a matcher that matches when a map has key == expected
func Length ¶
Length can be called with arrays, maps, *gocrest.Matcher and strings but not numeric types. has.Length(is.GreaterThan(x)) is a valid call. Returns a matcher that matches if the length matches the given criteria
func Prefix ¶
Prefix returns a matcher that matches if the given string is prefixed with the expected string Function panics if the actual is not a string. Uses strings.Prefix(act, exp) to evaluate strings. Returns a matcher that returns true if the above conditions are met
func StructWithValues ¶ added in v1.0.5
func StructWithValues(expects StructMatchers) *gocrest.Matcher
Checks whether the actual struct matches all expectations passed as StructMatchers. This method can be used to check single struct fields in different ways or omit checking some struct fields at all. Panics if the actual value is not a struct. Panics if Structmatchers contains a key that can not be found in the actual struct. Panics if Structmatchers contains a key that is unexported.
func Suffix ¶
Suffix returns a matcher that matches if the given string is suffixed with the expected string. Panics if the actual is not a string. Uses strings.HasSuffix(act,exp) to evaluate strings. Returns a matcher that returns true if the above conditions are met.
Types ¶
type StructMatchers ¶ added in v1.0.5
Type that can be passed to StructWithValues. Mapps Struct field names to a matcher