test

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package test defines a tree structure that describes the tests loaded from one or more Aureus Markdown documents.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assertion

type Assertion struct {
	Input  Content
	Output Content
}

Assertion represents a requirement that an input match a specific output.

type Content

type Content struct {
	// ContentMetaData is additional information about the content.
	ContentMetaData

	// Data is the content itself.
	Data []byte
}

Content is data used as input or output in tests.

type ContentMetaData

type ContentMetaData 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

	// 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
}

ContentMetaData contains information about input or output content.

func (ContentMetaData) IsEntireFile added in v0.2.4

func (m ContentMetaData) IsEntireFile() bool

IsEntireFile returns true if the content occupies the entire file.

type Option

type Option func(*Test)

Option is an option that controls how a test is created by New.

func WithAssertions added in v0.2.0

func WithAssertions(assertions ...Assertion) Option

WithAssertions is a [TestOption] thatadds assertions to the test.

func WithSkip

func WithSkip(skip bool) Option

WithSkip is a [TestOption] that sets the skip flag.

func WithSubTests

func WithSubTests(subTests ...Test) Option

WithSubTests is a [TestOption] that adds sub-tests to the test.

type Test

type Test struct {
	Name       string
	Skip       bool
	SubTests   []Test
	Assertions []Assertion
}

Test is a (possibly nested) test.

func Merge added in v0.2.2

func Merge(tests ...Test) []Test

Merge recursively combines tests with the same name into a single test.

func New

func New(name string, options ...Option) Test

New creates a new Test.

It returns the test and the set of flags that should be inherited by any sub-tests.

func (Test) IsEmpty added in v0.2.2

func (t Test) IsEmpty() bool

IsEmpty returns true if the test has no sub-tests or assertions.

type TestingT

type TestingT interface {
	Helper()
}

TestingT is the subset of the *testing.T interface that is used when dispatching a visitor to ensure that the internals of the visitor mechanism are properly marked as test helpers.

type VisitOption

type VisitOption func(*visitConfig)

VisitOption is an option for configuring a visitor.

func WithT

func WithT(t TestingT) VisitOption

WithT configures the visitor to use t to mark the internal mechanism of the visitor as test helpers.

Jump to

Keyboard shortcuts

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