Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Equal ¶
Equal checks if got is equal to the saved `testdata/<test name>.golden` test file. If it is not, t.Fatal is called with a multi-line diff comparison.
If the `go test -update` flag is specified, the .golden files will be updated/created automatically.
If the input value is of type Raw, its contents will be directly used instead of the value being formatted as a Go literal.
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option configures specific behavior for Equal.
func Dir ¶
Dir specifies a customer directory to use for writing the golden files, instead of the default "testdata/".
func ExportedOnly ¶ added in v0.9.5
func ExportedOnly() Option
ExportedOnly is an option that includes exported fields in the output only.
type Value ¶ added in v0.9.5
type Value interface {
// Name returns the value name.
Name() string
// Equal checks if `got` matches the desired test value, invoking t.Fatal otherwise.
Equal(t *testing.T, got interface{}, opts ...Option)
}
Value describes a desired value for a Go test, see Want for more information.
func Want ¶ added in v0.9.5
Want returns a desired Value which can later be checked for equality against a gotten value.
The name parameter must be a Go string literal (NOT a variable or expression), and must be unique within the Go test function.
When `-update` is specified, autogold will find and replace in the test file by looking for an instance of e.g. `autogold.Want("bar", ...)` beneath the calling `TestFoo` function and replacing the `want` value parameter.