Documentation
¶
Overview ¶
Package testutil provides utilities for Go testing including golden file management.
Index ¶
- Variables
- type GoldenFile
- func (g *GoldenFile) Assert(actual []byte)
- func (g *GoldenFile) AssertString(actual string)
- func (g *GoldenFile) Compare(actual []byte) error
- func (g *GoldenFile) CompareString(actual string) error
- func (g *GoldenFile) Exists() bool
- func (g *GoldenFile) Path() string
- func (g *GoldenFile) Read() ([]byte, error)
- func (g *GoldenFile) ReadString() (string, error)
- func (g *GoldenFile) WithDir(dir string) *GoldenFile
- type GoldenMismatch
Constants ¶
This section is empty.
Variables ¶
var UpdateGoldenFiles = flag.Bool("update", false, "Update golden files")
UpdateGoldenFiles is set by the -update flag to regenerate golden files
Functions ¶
This section is empty.
Types ¶
type GoldenFile ¶
type GoldenFile struct {
// contains filtered or unexported fields
}
GoldenFile represents a golden file for snapshot testing
func NewGolden ¶
func NewGolden(t *testing.T, name string) *GoldenFile
NewGolden creates a new golden file handler
func (*GoldenFile) Assert ¶
func (g *GoldenFile) Assert(actual []byte)
Assert compares and fails the test if mismatch
func (*GoldenFile) AssertString ¶
func (g *GoldenFile) AssertString(actual string)
AssertString compares string and fails the test if mismatch
func (*GoldenFile) Compare ¶
func (g *GoldenFile) Compare(actual []byte) error
Compare compares the actual output against the golden file
func (*GoldenFile) CompareString ¶
func (g *GoldenFile) CompareString(actual string) error
CompareString compares string output against golden file
func (*GoldenFile) Exists ¶
func (g *GoldenFile) Exists() bool
Exists checks if the golden file exists
func (*GoldenFile) Path ¶
func (g *GoldenFile) Path() string
Path returns the full path to the golden file
func (*GoldenFile) Read ¶
func (g *GoldenFile) Read() ([]byte, error)
Read reads the golden file content
func (*GoldenFile) ReadString ¶
func (g *GoldenFile) ReadString() (string, error)
ReadString reads the golden file as string
func (*GoldenFile) WithDir ¶
func (g *GoldenFile) WithDir(dir string) *GoldenFile
WithDir sets a custom directory for the golden file
type GoldenMismatch ¶
GoldenMismatch represents a mismatch between expected and actual output
func (*GoldenMismatch) Diff ¶
func (m *GoldenMismatch) Diff() string
Diff returns a simple diff of expected vs actual
func (*GoldenMismatch) Error ¶
func (m *GoldenMismatch) Error() string