test

package
v0.0.0-...-674084c Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Namer

type Namer func(script string) string

Namer names things. Namer functions take the script under test as intput and returns the name. Namer functions are used to customize how files and directories are named.

type Options

type Options struct {
	// Name is the test name. This value is used as the go test name. When left
	// empty, the script file name is used to derive the test name.
	Name string

	// WorkingDirectory is a directory to change to before executing the test.
	WorkingDirectory string

	// Env is additional environment entries for the command run.
	// These will be expanded in the commands themselves, if they are
	// supplied in a *.cmd file, since it is executed via `sh`.
	Env []string

	// CommandFile is a Namer that returns how files containing the list of
	// commands to run for a test should be named. It defaults to $script.cmd.
	CommandFile Namer

	// OutputDirectory is a Namer that returns how to name the directory the script
	// should output generated files to. It defaults to:
	//   echo $(echo $script | cut -f 1 -d '.').got
	OutputDirectory Namer

	// ExpectedOutputFile is a Namer that returns how files containing the expected
	// stdout should be named. It defaults to $script.expected.
	ExpectedOutputFile Namer

	// ExpectedOutputDirectory is a Namer that returns how the directory container
	// the expected generated names should be named. It defaults to:
	//   echo $(echo $script | cut -f 1 -d '.').expected
	ExpectedOutputDirectory Namer
}

Options are options that can be specified when creating a Test.

type Test

type Test struct {
	// contains filtered or unexported fields
}

Test is a end to end test, corresponding to one test-$testname.js file.

func New

func New(script string, options ...Options) *Test

New creates a new Test wrapping the given jk script.

func (*Test) Name

func (test *Test) Name() string

Name is the test name.

func (*Test) Run

func (test *Test) Run(t *testing.T)

Run executes the test and compare its output to the expected state.

Jump to

Keyboard shortcuts

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