test

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgainstGolden

func AgainstGolden[T any](
	t TestingT,
	regenerate bool,
	got T,
	goldenPath string,
	helpers ...GoldenHelper,
)

AgainstGolden compares a result against the contents of the file at the goldenPath. Run with regenerate set to true to create or update the file.

func EqualDiffWithOptionsf

func EqualDiffWithOptionsf[T any](
	t TestingT,
	want T, got T,
	opts cmp.Options,
	format string, a ...any,
)

EqualDiffWithOptionsf runs a cmp.Diff with protobuf-specific options.

func Mustf

func Mustf(t TestingT, err error, format string, a ...any)

func Regenerate

func Regenerate() bool

func UnmarshalFile

func UnmarshalFile(path string, o any) (outErr error)

UnmarshalFile is a utility function for reading and unmarshalling a file containing JSON. The parsing will be strict and disallow unknown fields.

Types

type GoldenHelper

type GoldenHelper interface {
	CmpOpts() cmp.Options
	JSONTransform(value map[string]any) error
}

type GoldenHelperForAny

type GoldenHelperForAny interface {
	JSONTransformAny(value any) error
}

type SortMapStringKeys

type SortMapStringKeys struct{}

func (SortMapStringKeys) CmpOpts

func (fi SortMapStringKeys) CmpOpts() cmp.Options

CmpOpts implements GoldenHelper.

func (SortMapStringKeys) JSONTransform

func (fi SortMapStringKeys) JSONTransform(_ map[string]any) error

JSONTransform implements GoldenHelper.

type TestingT

type TestingT interface {
	Helper()
	Fatalf(format string, args ...any)
	Logf(format string, args ...any)
}

Jump to

Keyboard shortcuts

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