Documentation
¶
Index ¶
- Variables
- type Expect
- type Option
- type Test
- type Val
- func (e Val) First() Val
- func (e Val) Last() Val
- func (e Val) Message() Val
- func (e Val) NotToBe(unExpected interface{}) Val
- func (e Val) ToBe(expected interface{}) Val
- func (e Val) ToBeAbout(expected, delta float64) Val
- func (e Val) ToBeSnapshot(path string) Val
- func (e Val) ToBeSnapshotImage(path string, opts ...Option) Val
- func (e Val) ToBeType(t any) Val
- func (e Val) ToContain(expected interface{}) Val
- func (e Val) ToCount(c int) Val
- func (e Val) ToHavePrefix(prefix string) Val
- func (e Val) ToHaveSuffix(suffix string) Val
Constants ¶
This section is empty.
Variables ¶
var ( PlainOutput = output("plain") ColoredDiffOutput = output("coloredDiffOutput") )
var Default = &Expect{ Output: PlainOutput, }
Functions ¶
This section is empty.
Types ¶
type Expect ¶
type Expect struct {
Output output
}
type Option ¶ added in v0.12.5
type Option interface {
// contains filtered or unexported methods
}
func WithMatchTolerance ¶ added in v0.12.5
WithMatchTolerance sets the maximum fraction of pixels that may differ while still accepting the image. 0 means no mismatches allowed. 1 means all mismatches allowed.
func WithPixelTolerance ¶ added in v0.12.5
WithPixelTolerance sets the maximum allowed color difference for a pixel to be considered a match. 0 means exact match only. 1 means all pixels matched.
type Test ¶
type Test interface {
Fatalf(f string, i ...interface{})
Errorf(f string, i ...interface{})
Error(p ...interface{})
Helper()
}
Test implements testing.T methods used by expect. Necessary to: - allow usage of testing.T and testing.B instances - for running tests
type Val ¶
type Val struct {
// contains filtered or unexported fields
}
Val to call expectations on.
func Error ¶
Error wraps an error and provides expectations for this value. It delegates to the default instance `Default`.
func Value ¶
Value wraps a value and provides expectations for this value. It delegates to the default instance `Default`.
func (Val) Message ¶
Message creates a new value from the given errors message. If the error is nil the message wil be the empty string.
func (Val) ToBeAbout ¶
ToBeAbout asserts that the number is in deltas range of expected value. Only works for numbers.
func (Val) ToBeSnapshot ¶ added in v0.10.1
func (Val) ToBeSnapshotImage ¶ added in v0.11.0
ToBeSnapshotImage saves the image in the first run, in later runs, compares the image to the saved one. If they are not the same it will write a .current.pn and .diff.png version of the image. The images match by default when 99% of the pixels colors are by less than 10% off. The Parameter SnapshotImageOptionExact forces the images to be exactly the same.
func (Val) ToContain ¶ added in v0.10.3
ToContain checks if the expected value is in the expected slice or if the string contains a substring or not. Does a deep equal for slices.
func (Val) ToCount ¶
ToCount asserts that the list/map/chan/string has c elements. Strings use the number of unicode chars.
func (Val) ToHavePrefix ¶
ToHavePrefix asserts that the string value starts with the provided prefix.
func (Val) ToHaveSuffix ¶
ToHaveSuffix asserts that the string value ends with the provided sufix.