Documentation
¶
Overview ¶
Package loader loads tests from various sources.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Content ¶
type Content struct { // Role is the role that the content plays within a test. A value of // [NoRole] indicates that the content has no specific role within the test. Role ContentRole // Group is the name of the group to which the content belongs. Inputs and // outputs in the same group form a matrix of test cases. Group *Group // Caption is an optional disambiguating name, title or short description of // the content. Caption string // Language is the language of the content, if known, e.g. "json", "yaml", // etc. Content with an empty language is treated as plain text. Language string // Attributes is a set of key-value pairs that provide additional // loader-specific information about the data. Attributes map[string]string // Data is the content itself. Data []byte }
Content is a specialization of test.Content that includes meta-data about how it was loaded and how it should appear within tests.
type ContentEnvelope ¶
type ContentEnvelope struct { // File is the path of the file from which the content was loaded. File string // Line is the line number within the file where the content begins, or 0 if // the content represents the entire file. Line int // The half-open range [Begin, End) is the section within the file that // contains the content, given in bytes. // // If the range is [0, 0), the content represents the entire file. Begin, End int64 // Skip is a flag that indicates whether this content should be skipped when // running tests. Skip bool // Content is the loaded content. Content Content }
ContentEnvelope is a container for Content and meta-data about how it was loaded.
func SeparateContentByRole ¶
func SeparateContentByRole(content []ContentEnvelope) (inputs, outputs []ContentEnvelope)
SeparateContentByRole separates content into inputs and outputs.
func (ContentEnvelope) AsTestContent ¶
func (e ContentEnvelope) AsTestContent() test.Content
AsTestContent returns the content as a test.Content.
func (ContentEnvelope) IsEntireFile ¶ added in v0.2.4
func (e ContentEnvelope) IsEntireFile() bool
IsEntireFile returns true if the content occupies the entire file.
type ContentRole ¶
type ContentRole int
ContentRole is an enumeration of the roles that loaded content can play within in a test.
const ( // NoRole indicates that the content has no specific role within the test. NoRole ContentRole = iota // Input indicates that the content is an input to a test. Input // Output indicates that the content is the expected output from a test. Output )
type Group ¶ added in v0.2.8
type Group struct {
// contains filtered or unexported fields
}
Group is the group to which content belongs. Inputs and outputs in the same group form a matrix of test cases.
func NamedGroup ¶ added in v0.2.8
NamedGroup returns a Group with the given name.
func UnnamedGroup ¶ added in v0.2.8
func UnnamedGroup() *Group
UnnamedGroup returns a Group with no name.
type NoInputsError ¶ added in v0.2.0
type NoInputsError struct {
Outputs []ContentEnvelope
}
NoInputsError is an error that occurs when a test cannot be built because it has at least one input but no outputs.
func (NoInputsError) Error ¶ added in v0.2.0
func (e NoInputsError) Error() string
type NoOutputsError ¶ added in v0.2.0
type NoOutputsError struct {
Inputs []ContentEnvelope
}
NoOutputsError is an error that occurs when a test cannot be built because it has at least one output but no inputs.
func (NoOutputsError) Error ¶ added in v0.2.0
func (e NoOutputsError) Error() string
type TestBuilder ¶
type TestBuilder struct {
// contains filtered or unexported fields
}
TestBuilder builds test.Test values from groups of correlated inputs and outputs.
func (*TestBuilder) AddContent ¶
func (b *TestBuilder) AddContent(env ContentEnvelope) error
AddContent adds content to the builder.
Content with no [Role] is ignored.
func (*TestBuilder) AddTest ¶
func (b *TestBuilder) AddTest(t test.Test)
AddTest adds a pre-built test to the builder.
Empty tests are ignored.
Directories
¶
Path | Synopsis |
---|---|
Package fileloader loads test.Test values from files containing test inputs and expected outputs.
|
Package fileloader loads test.Test values from files containing test inputs and expected outputs. |
internal
|
|
loadertest
Package loadertest provides a basic golden-file style test running for testing Aureus' internal loader implementations.
|
Package loadertest provides a basic golden-file style test running for testing Aureus' internal loader implementations. |
Package markdownloader loads test.Test values from Markdown files containing code blocks representing test inputs and expected outputs.
|
Package markdownloader loads test.Test values from Markdown files containing code blocks representing test inputs and expected outputs. |