Documentation
¶
Index ¶
Constants ¶
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 ¶
var ( // GoldenFileDirPath is the full relative path to the golden files directory. GoldenFileDirPath = filepath.Join(TestFixturesDir, GoldenFileDirName) )
Functions ¶
func DangerText ¶
DangerText wraps text in ANSI escape codes for reverse red to make it highly visible.
func GetFixturePath ¶
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 ¶
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.
func OpenDescriptorBaseline ¶ added in v0.3.4
OpenDescriptorBaseline is OpenDescriptorCount for the "before" side of a leak check. The count is process wide, so an *os.File some earlier test dropped without closing is still counted until a GC runs its cleanup. If that GC lands inside the window under test the count drops and the check fails for code it never ran. This forces those cleanups first so the baseline only holds live descriptors.
Only the baseline flushes: doing the same on the "after" side would let GC close a descriptor the code under test leaked, which is exactly what the check is meant to catch.
func OpenDescriptorCount ¶ added in v0.3.2
OpenDescriptorCount reports how many file descriptors this process currently holds. Use it to assert that a code path released what it opened: on unix a leaked descriptor is otherwise invisible, since unlinking a file succeeds while a handle to it is still open.
Reads /dev/fd with Readdirnames rather than os.ReadDir, which stats each entry and fails on darwin for the directory handle doing the reading.
Types ¶
This section is empty.