Documentation ¶
Overview ¶
Package markdownloader loads test.Test values from Markdown files containing code blocks representing 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 ¶
type ContentLoader func( headings []string, info, code string, ) (_ loader.Content, skip bool, _ error)
A ContentLoader is a function that returns content obtained from a fenced code block.
headings is a list of headings that precede the code block in the document, which may be empty. The last element of the list is the heading that the code block is "within".
info is the "info string" of the code block, that is, the line of text that contains the language and other loader-specific information.
type LoadOption ¶
type LoadOption func(*loadOptions)
LoadOption is an option that changes the behavior of a Loader.
func WithContentLoader ¶
func WithContentLoader(load ContentLoader) LoadOption
WithContentLoader is a LoadOption that configures an alternative ContentLoader used to load content from code blocks.
func WithFS ¶
func WithFS(f fs.FS) LoadOption
WithFS is a LoadOption that configures an alternative filesystem to use when loading tests.
func WithParser ¶
func WithParser(p parser.Parser) LoadOption
WithParser is a LoadOption that configures an alternative Markdown parser to use when loading tests.
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 Markdown files containing code blocks representing 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.