testutil

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TestFixturesDir is the standard directory name for test fixtures.
	// This follows the Go convention of using "testdata" for test assets.
	TestFixturesDir = "testdata"

	// LegacyTestFixturesDir is the previous directory name used for test fixtures.
	// Files here will be automatically migrated to TestFixturesDir when accessed.
	LegacyTestFixturesDir = "test-fixtures"

	// GoldenFileDirName is the subdirectory within TestFixturesDir for golden files.
	GoldenFileDirName = "snapshot"

	// GoldenFileExt is the file extension for golden files.
	GoldenFileExt = ".golden"
)

Variables

View Source
var (
	// GoldenFileDirPath is the full relative path to the golden files directory.
	GoldenFileDirPath = filepath.Join(TestFixturesDir, GoldenFileDirName)
)

Functions

func DangerText

func DangerText(s string) string

DangerText wraps text in ANSI escape codes for reverse red to make it highly visible.

func GetFixturePath

func GetFixturePath(t testing.TB, pathParts ...string) string

GetFixturePath returns the path to a test fixture, automatically migrating from the legacy "test-fixtures" directory to "testdata" if needed. The migration happens transparently on first access.

func GetTestFixturesDir

func GetTestFixturesDir(t testing.TB) string

GetTestFixturesDir returns the fixture directory path, automatically migrating from the legacy "test-fixtures" directory if needed. This is useful for cases like afero.NewBasePathFs where you need the entire fixtures directory as a base.

Types

This section is empty.

Jump to

Keyboard shortcuts

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