Documentation ¶
Overview ¶
Package fileloader loads test.Test values from files containing test inputs and expected outputs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadContent ¶
LoadContent is the default ContentLoader implementation.
Types ¶
type ContentLoader ¶
A ContentLoader is a function that returns content read from a file.
name is the "effective" or "sanitized" name of the file, after any special characters have been removed by the loader. For example, a leading underscore. The f.Stat() method can be used to get the actual file name.
If the returned content's role is loader.NoRole, it is ignored.
type LoadOption ¶
type LoadOption func(*loadOptions)
LoadOption is an option that changes the behavior of a Loader.
func WithFS ¶
func WithFS(f fs.FS) LoadOption
WithFS is a LoadOption that configures an alternative filesystem to use when loading tests.
func WithFileLoader ¶
func WithFileLoader(load ContentLoader) LoadOption
WithFileLoader is a LoadOption that configures an alternative [FileLoader] used to identify test files and load their content.
func WithRecursion ¶
func WithRecursion(on bool) LoadOption
WithRecursion if a LoadOption that enables or disables recursive scanning of sub-directories.
Recursion is enabled by default.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader loads test.Test values from files containing test inputs and expected outputs.
func NewLoader ¶
func NewLoader(options ...LoadOption) *Loader
NewLoader returns a new Loader, which loads golden file tests from the filesystem.