Documentation
¶
Index ¶
- Variables
- func Cleanup() error
- func FromOSDependentSnapshot(t *testing.T, name string, comparable snapshots.Comparable)
- func FromOSDependentSnapshotWithConfig(t *testing.T, name string, comparable snapshots.Comparable, config *Config)
- func FromSnapshot(t *testing.T, name string, comparable snapshots.Comparable)
- func FromSnapshotWithConfig(t *testing.T, name string, comparable snapshots.Comparable, config *Config)
- func MustCleanup() error
- type Args
- type Config
- type ErrRepeated
- type ErrTestErrored
- type ErrTestFailed
- type Grouping
Constants ¶
This section is empty.
Variables ¶
var ErrNotSnapshotted = errors.New("not snapshotted")
Functions ¶
func Cleanup ¶
func Cleanup() error
Cleanup should be called in TestMain AFTER m.Run() to remove stale snapshots
func FromOSDependentSnapshot ¶
func FromOSDependentSnapshot(t *testing.T, name string, comparable snapshots.Comparable)
FromOSDependentSnapshot will fail if the stored information is not equal (in a non-agnostic comparison) to the passed comparabletypes but only if the OS of both matches, this should prevent weird side effect of snapshotting in different machines.
func FromOSDependentSnapshotWithConfig ¶ added in v0.0.6
func FromOSDependentSnapshotWithConfig(t *testing.T, name string, comparable snapshots.Comparable, config *Config)
FromOSDependentSnapshotWithConfig will fail if the stored information is not equal (in a non-agnostic comparison) to the passed comparabletypes but only if the OS of both matches, this should prevent weird side effect of snapshotting in different machines, the config will be overriden/updated with the passed one
func FromSnapshot ¶
func FromSnapshot(t *testing.T, name string, comparable snapshots.Comparable)
FromSnapshot will fail if the stored information is not equal (in a non-agnostic comparison) to the passed comparabletypes.
func FromSnapshotWithConfig ¶ added in v0.0.6
func FromSnapshotWithConfig(t *testing.T, name string, comparable snapshots.Comparable, config *Config)
FromSnapshotWithConfig will fail if the stored information is not equal (in a non-agnostic comparison) to the passed comparabletypes, the config will be overriden/updated with the passed one.
func MustCleanup ¶
func MustCleanup() error
MustCleanup will do exactly as Cleanup but also fail if a cleanup was due and no flag was passed
Types ¶
type Config ¶
type Config struct {
Grouping Grouping `json:"grouping,omitempty"`
SnapShotDir string `json:"snapshot_dir,omitempty"`
// Replacers holds possible kw replacement as map[comparabletypes.Kind]map[from]to
Replacers map[snapshots.Kind]map[string]string `json:"replacers,omitempty"`
}
Config holds the config we allow for a test suite.
func ReadConfig ¶
ReadConfig will try to read a config file from cwd and return that or a sane default.
func (*Config) SnapshotDir ¶
SnapshotDir will return either: * The user configured snapshot directory * The default directory name we use for snapshots * In case "per file" snapshots are chosen: File_test.expectations
type ErrRepeated ¶
type ErrRepeated struct {
// contains filtered or unexported fields
}
func (*ErrRepeated) Error ¶
func (e *ErrRepeated) Error() string
func (*ErrRepeated) Is ¶
func (e *ErrRepeated) Is(err error) bool
type ErrTestErrored ¶
type ErrTestErrored struct {
// contains filtered or unexported fields
}
ErrTestErrored should be returned when one of the preconditions or setups of the tests errored
func (*ErrTestErrored) Error ¶
func (e *ErrTestErrored) Error() string
Error implements errors for ErrTestErrored
func (*ErrTestErrored) Is ¶
func (e *ErrTestErrored) Is(err error) bool
Is implements the (for some unspoken reason) tacit errors.Is interface for ErrTestErrored
func (*ErrTestErrored) Unwrap ¶
func (e *ErrTestErrored) Unwrap() error
Unwrap implements the (for some unspoken reason) tacit errors.Unwrap() interface for ErrTestErrored
type ErrTestFailed ¶
type ErrTestFailed struct {
// contains filtered or unexported fields
}
ErrTestFailed should be returned when a comparison test fails.
func (*ErrTestFailed) Error ¶
func (e *ErrTestFailed) Error() string
Error implements errors for ErrTestFailed
func (*ErrTestFailed) Is ¶
func (e *ErrTestFailed) Is(err error) bool
Is implements the (for some unspoken reason) tacit errors.Is interface for ErrTestFailed
