snapshot

package
v0.5.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Record

func Record(
	t testing.TB,
	got interface{},
) interface{}

Record saves data

func Take

func Take(
	t testing.TB,
	got interface{},
	options ...func(*Config),
) interface{}

Take snapshot tests if needed and return expected data

func WithForceUpdate

func WithForceUpdate() func(*Config)

WithForceUpdate :

func WithMetadata

func WithMetadata(metadata map[string]interface{}) func(*Config)

WithMetadata :

func WithReplaceMap

func WithReplaceMap(repMap map[string]interface{}) func(*Config)

WithReplaceMap replace data when loading stored data

func WithReplaceMapNormalized

func WithReplaceMapNormalized(repMap map[string]interface{}) func(*Config)

WithReplaceMapNormalized replace data when loading stored data

func WithUpdateByEnvvar

func WithUpdateByEnvvar(s string) func(*Config)

WithUpdateByEnvvar :

Types

type Config

type Config struct {
	Recorder *Recorder
	Extra    *Extra

	Overwrite bool
	// contains filtered or unexported fields
}

Config :

func (*Config) Run

func (c *Config) Run(
	t testing.TB,
	got interface{},
) interface{}

Run :

type Extra

type Extra struct {
	ReplaceMap map[string]interface{} // data replacement setting, on loading
	Metadata   map[string]interface{}
}

Extra is extra data

type Loader

type Loader struct {
	Encode func(io.Writer, interface{}, *Extra) error
	Decode func(io.Reader, interface{}, *Extra) error
}

Loader :

func NewJSONLoader

func NewJSONLoader() *Loader

NewJSONLoader :

func (*Loader) Load

func (r *Loader) Load(fpath string, want interface{}, extra *Extra) (err error)

func (*Loader) Save

func (r *Loader) Save(fpath string, val interface{}, extra *Extra) (err error)

Save :

type Recorder

type Recorder struct {
	Exists func(string) bool
	Path   func(testing.TB) string
	Loader *Loader
}

Recorder :

func NewTestdataRecorder

func NewTestdataRecorder(loader *Loader) *Recorder

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL