testutil

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const GoldenUpdateEnv = `TESTUTIL_UPDATE_GOLDEN`

Variables

This section is empty.

Functions

func AssertGolden

func AssertGolden(t TB, filename string, data []byte)

AssertGolden tests, if the content of filename matches given data. On missmatch the test fails. When setting the TESTUTIL_UPDATE_GOLDEN environment variable, it will update the file which can be compared via a VCS diff.

func AssertGoldenDiff

func AssertGoldenDiff(t TB, filename string, a, b string)

AssertGoldenDiff creates a unified diff of two texts and compares it with the golden file.

func AssertGoldenDiffJSON

func AssertGoldenDiffJSON(t TB, filename string, a, b interface{})

AssertGoldenDiffJSON works like AssertGoldenDiff, but converts the data to JSON first.

func AssertGoldenJSON

func AssertGoldenJSON(t TB, filename string, data interface{})

AssertGoldenJSON works like AssertGolden, but converts the data to JSON file.

func AssertGoldenYAML

func AssertGoldenYAML(t TB, filename string, data interface{})

AssertGoldenYAML works like AssertGolden, but converts the data to YAML file.

Types

type TB

type TB interface {
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Log(args ...interface{})
}

TB is a interface that is a subset of the testing.TB interface and therefore every *testing.T struct can be used.

Jump to

Keyboard shortcuts

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