fftest

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(want, have *Vars) error

Compare one set of vars with another and return an error on any difference.

func CreateTempFile added in v1.3.0

func CreateTempFile(t *testing.T, content string) (filename string, cleanup func())

CreateTempFile creates a temporary file in os.TempDir with the given content. Call the cleanup func to remove the file.

Types

type Vars

type Vars struct {
	S string
	I int
	F float64
	B bool
	D time.Duration

	// ParseError should be assigned as the result of Parse in tests.
	ParseError error

	// If a test case expects an input to generate a parse error,
	// it can specify that error here. The Compare helper will
	// look for it using xerrors.Is.
	WantParseErrorIs error

	// If a test case expects an input to generate a parse error,
	// it can specify part of that error string here. The Compare
	// helper will look for it using strings.Contains.
	WantParseErrorString string
}

Vars are a common set of variables used for testing.

func NewPair added in v1.3.0

func NewPair() (*flag.FlagSet, *Vars)

NewPair returns a predefined flag set, and a predefined set of variables that have been registered into it. Tests can call parse on the flag set with a variety of flags, config files, and env vars, and check the resulting effect on the vars.

Jump to

Keyboard shortcuts

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