testsupport

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUpdate

func IsUpdate() bool

IsUpdate returns true if the -update flag was passed to the test.

func MkdirTemp

func MkdirTemp(t *testing.T) (string, func())

MkdirTemp creates a temporary directory.

It returns the path to the created temporary directory and a clean-up function which allows to delete it.

func ProjectRoot

func ProjectRoot(t *testing.T) string

ProjectRoot searches from the current working directory upwards until it finds a go.mod file. The directory containing the go.mod file is then assumed to be the root of this project.

Types

type Converter

type Converter func(in io.Reader, out io.Writer) error

Converter defines a type that is capable from converting some input to some output.

type ConverterTest

type ConverterTest struct {
	Name         string // Name of the test case. Derived from InFile if empty.
	InputFile    string // Input file for the test case.
	ExpectedFile string // File containing expected output.

	Converter Converter // The converter to test.
}

ConverterTest is a test case for a conversion from one file format to another.

The default name of the converter test case is derived from the name of the input file. The default name can be overridden by setting the Name field.

If the -update flag is passed to the test, the ConverterTest writes any output produced to the ExpectedFile before comparison.

func FindConverterTests

func FindConverterTests(t *testing.T, dir, glob string, c Converter) []*ConverterTest

FindConverterTests searches dir for files matching glob and creates a converter test from them.

All expectation files created by converter tests have the name of the respective input file with the suffix .golden appended to them.

func (*ConverterTest) Run

func (tt *ConverterTest) Run(t *testing.T)

Run runs the converter test case.

Jump to

Keyboard shortcuts

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