Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AvailableStrategies = map[string]Strategy{ "strict": StrictEqualStrategy, "type": TypeEqualStrategy, }
Mapped list of available strategies
Functions ¶
This section is empty.
Types ¶
type Archetype ¶
type Archetype struct { Value interface{} `json:"value"` Strategy string `json:"strategy"` }
Archetype allows the developer to define certain content to trigger a different assertion strategy instead of the default 'strict' strategy
func LoadArchetypes ¶
load archetypes from json encoded reader content
func (*Archetype) Fits ¶
returns whether a given example value fit the defined archetype @todo this is quite fragicle since a.Value and val can be of similar but unequal types: float64(42) int64(42) will not match
func (*Archetype) ToStrategy ¶
returns the assert strategy for the archetype
type AssertFunc ¶
type AssertFunc func(expected, actual interface{}) error
func Parse ¶
func Parse(example interface{}, ats []*Archetype) (AssertFunc, error)
parse an example value to determine how the actual value will be asserted, (e.g. strict equal, type only)
func StrictEqualStrategy ¶
func StrictEqualStrategy() AssertFunc
Actual value should be exactly equal to the example
func TypeEqualStrategy ¶
func TypeEqualStrategy() AssertFunc
Actual value only needs to be of the same type as the example
type Strategy ¶
type Strategy func() AssertFunc