testutil

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package testutil provides utilities for golden file testing.

Index

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

func AssertGoldenJSON(t *testing.T, feature, name string, actualJSON []byte)

AssertGoldenJSON compares JSON output with golden file

func CompareWithGolden

func CompareWithGolden(t *testing.T, feature, name string, actual interface{})

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

func GetGoldenPath(feature, name string) string

GetGoldenPath returns the path to a golden file

func LoadGoldenFile

func LoadGoldenFile(t *testing.T, feature, name string) interface{}

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

Jump to

Keyboard shortcuts

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