test

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 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 interface {
	AcceptVisitor(AssertionVisitor, ...VisitOption)
}

Assertion is an interface for an assertion made by a Test.

type AssertionVisitor

type AssertionVisitor interface {
	VisitEqualAssertion(EqualAssertion)
}

AssertionVisitor is an interface for dispatching based on the concrete type of an Assertion.

type Content

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

	// Data is the content itself. It is always considered to be human-readable
	// text, such as source code.
	Data string
}

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 `json:",omitempty"`
	// 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 `json:",omitempty"`

	// Attributes is a set of key-value pairs that provide additional
	// loader-specific information about the data.
	Attributes map[string]string `json:",omitempty"`
}

ContentMetaData contains information about input or output content.

type EqualAssertion

type EqualAssertion struct {
	Input  Content
	Output Content
}

EqualAssertion is an Assertion that asserts that asserts two values are equal.

func (EqualAssertion) AcceptVisitor

func (a EqualAssertion) AcceptVisitor(v AssertionVisitor, options ...VisitOption)

AcceptVisitor dispatches to the appropriate method on v based on the concrete type of a.

type Option

type Option func(*Test)

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

func WithAssertion

func WithAssertion(a Assertion) Option

WithAssertion is a [TestOption] that sets the assertion on 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      `json:",omitempty"`
	SubTests  []Test    `json:",omitempty"`
	Assertion Assertion `json:",omitempty"`
}

Test is a (possibly nested) 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.

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