goldentest

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package goldentest is a utility to help create tests that compare a result (e.g. serialized data or formatted text) against a golden file stored in testdata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(t *testing.T, goldenPath, actual string)

Check looks for a file at testdata/{t.Name()}/[goldenPath], compares [actual] against the content, and causes the test to fail if it's incorrect.

If [goldenPath] starts with '*' and optionally has some characters after, the content is instead looked for at testdata/{t.Name()}[after]. Use this if dirs aren't useful for organization. After the '*' is typically a file extension, or perhaps extra context clues.

If "-update" or "-args update" is passed to the "go test" command, instead of failing, writes [actual] to the file.

func CheckFullPath added in v0.0.7

func CheckFullPath(t *testing.T, path, actual string)

CheckFullPath behaves like Check, but takes a full path to the golden file.

Types

This section is empty.

Jump to

Keyboard shortcuts

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