testhelper

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error added in v0.8.0

func Error() error

Error returns an internal error for testing

func HijackStandardStreams added in v0.8.0

func HijackStandardStreams(stdin, stdout, stderr *os.File, do func())

func NewAlwaysErrFS added in v0.8.0

func NewAlwaysErrFS(err error) fs.FS

NewAlwaysErrFS creates an fs.FS that always fail at Open() call with provided err

if err is nil, fs.ErrInvalid is returned by default

func NewAlwaysFailReader added in v0.8.0

func NewAlwaysFailReader(err error) io.Reader

NewAlwaysFailReader creates an reader already fail on Read() call with provided err

if err is nil, an io.ErrUnexpectedEOF is returned by default

func TestFixtures

func TestFixtures[TestCase, Expected any](
	t *testing.T,
	dir string,
	createTestSpec func() TestCase,
	createExpected func() Expected,
	check func(t *testing.T, spec TestCase, exp Expected),
)

TestFixtures run tests using multi-doc yaml file

# first doc is the test spec some_args: ... spec:

a: b

--- # second doc is the expected result c: d

Types

type AlwaysErrFS added in v0.10.1

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

func (AlwaysErrFS) Open added in v0.10.1

func (fs AlwaysErrFS) Open(name string) (fs.File, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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