Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoPath = errors.New("no golden file path") ErrNoMarshaller = errors.New("no marshaller") ErrNoDiffer = errors.New("no differ") ErrNotEqual = errors.New("not equal") )
Possible errors when invoking the Eq func.
View Source
var ErrUnsupportedType = errors.New("only []byte and string are supported by default, use a custom Marshaller, e.g. JSON")
ErrUnsupportedType is returned when encoding values other than string or a []byte using the DefaultMarshaller.
Functions ¶
This section is empty.
Types ¶
type Data ¶
type Data struct { Path string Perm os.FileMode Marsh Marshaller Diff Differ Transforms []Transformer Update bool }
Data represents the golden file attributes.
func (*Data) Add ¶
func (d *Data) Add(t Transformer) *Data
func (*Data) Eq ¶
Eq compares the value v to the contents of the golden file. If it's not equal, it returns the ErrNotEqual together with a diff string.
type Marshaller ¶
Marshaller returns v encoded as []byte.
var DefaultMarshaller Marshaller = func(v interface{}) ([]byte, error) { if v == nil { return nil, ErrUnsupportedType } switch v := v.(type) { case string: return []byte(v), nil case []byte: return v, nil default: return nil, ErrUnsupportedType } }
DefaultMarshaller can handle []byte or string type.
type Transformer ¶
Transformer transforms and returns t and u, respectively.
Click to show internal directories.
Click to hide internal directories.