testutil

package
v0.0.0-...-2ad639e Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InitNoopLogger = func(name string, vs ...interface{}) (log.Logger, error) {
	return &noopLogger{}, nil
}

InitNoopLogger is a init function to initialize a noop logger.

Functions

func AssertGolden

func AssertGolden(t testing.TB, path string, update bool, got interface{})

AssertGolden compares what's got and what's in the golden file. It updates the golden file on-demand. It does nothing when the runtime is "windows".

func Exec

func Exec(helper string, envs ...string) (string, error)

Exec executes "go test" on given helper with supplied environment variables. It is useful to mock "os/exec" functions in tests. When succeeded, it returns the result produced by the test helper. The test helper should:

  1. Use WantHelperProcess function to determine if it is being called in helper mode.
  2. Call fmt.Fprintln(os.Stdout, ...) to print results for the main test to collect.

func Update

func Update(name string) bool

Update returns true if update regex matches given test name.

func WantHelperProcess

func WantHelperProcess() bool

WantHelperProcess returns true if current process is in helper mode.

Types

This section is empty.

Jump to

Keyboard shortcuts

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