Documentation
¶
Overview ¶
Package testutil provides utilities for golden file testing.
Index ¶
- Variables
- func AssertGoldenJSON(t *testing.T, feature, name string, actualJSON []byte)
- func CompareWithGolden(t *testing.T, feature, name string, actual interface{})
- func CreateGoldenTest(t *testing.T, feature string, tests []struct{ ... })
- func DiffJSON(expected, actual interface{}) string
- func GetGoldenPath(feature, name string) string
- func LoadGoldenFile(t *testing.T, feature, name string) interface{}
- type GoldenFile
- type GoldenMeta
Constants ¶
This section is empty.
Variables ¶
View Source
var UpdateGoldens = os.Getenv("UPDATE_GOLDENS") == "true"
UpdateGoldens controls whether to update golden files Set via environment variable: UPDATE_GOLDENS=true go test ./...
Functions ¶
func AssertGoldenJSON ¶
AssertGoldenJSON compares JSON output with golden file
func CompareWithGolden ¶
CompareWithGolden compares actual output with golden file
func CreateGoldenTest ¶
func CreateGoldenTest(t *testing.T, feature string, tests []struct { Name string Data interface{} })
CreateGoldenTest creates a test that compares with golden files
func DiffJSON ¶
func DiffJSON(expected, actual interface{}) string
DiffJSON returns a string showing the differences between two JSON values
func GetGoldenPath ¶
GetGoldenPath returns the path to a golden file
func LoadGoldenFile ¶
LoadGoldenFile loads and returns a golden file's data
Types ¶
type GoldenFile ¶
type GoldenFile struct {
Meta GoldenMeta `json:"meta"`
Data interface{} `json:"data"`
}
GoldenFile represents a golden test file with metadata
type GoldenMeta ¶
type GoldenMeta struct {
GoVersion string `json:"go_version"`
OS string `json:"os"`
Arch string `json:"arch"`
}
GoldenMeta captures platform information for reproducibility
Click to show internal directories.
Click to hide internal directories.