Documentation ¶
Overview ¶
Package test is a set of helper functions of tests
Index ¶
- Constants
- func AssertInput(t *testing.T, input, got, exp interface{})
- func AssertLabel(t *testing.T, label string, got, exp interface{})
- func AssertLabelString(label string, got, exp interface{}) string
- func DiffString(label string, got, exp, diff interface{}) string
- func EnvSetting(t *testing.T, envKey, defaultValue string, callDefaultSettings func() string)
- func IfError(t *testing.T, err error)
- func PrintLogEntries(t *testing.T, hook *logTest.Hook)
- func RandSeed()
- func ReadFixture(t *testing.T, filename string) []byte
- func SafeLogEntries(hook *logTest.Hook) bool
- func SandboxDir(t *testing.T, originalPath string) (string, func())
- func Time(i int) time.Time
- func TimeDiff(callback func()) time.Duration
- func UpdateFixtureFlag() *bool
- func WriteFixture(t *testing.T, filename string, data []byte)
- type Context
- func (context *Context) DiffString(label string, got, exp, diff interface{}) string
- func (context *Context) FieldsString() string
- func (context *Context) GotExpString(label string, got, exp interface{}) string
- func (context *Context) SetFields(fields ContextFields) *Context
- func (context *Context) String(i interface{}) string
- func (context *Context) Stringf(format string, args ...interface{}) string
- type ContextFields
Constants ¶
const FixturePath = "./testdata"
FixturePath is the path of the fixtures
Variables ¶
This section is empty.
Functions ¶
func AssertInput ¶
AssertInput calls AssertLabel, but sets the context based on input
func AssertLabel ¶
AssertLabel does a simple assertion
func AssertLabelString ¶
AssertLabelString returns a string format for assertions
func DiffString ¶
DiffString returns a string format for diffs
func EnvSetting ¶
EnvSetting is a standard test for environment variables's interaction with DefaultSettings()
func PrintLogEntries ¶
PrintLogEntries prints all the log entries of the hook
func ReadFixture ¶
ReadFixture reads the fixture given the filename
func SafeLogEntries ¶
SafeLogEntries returns true if all log entries of hook are "safe" (not warnings or more dangerous)
func SandboxDir ¶
SandboxDir sets up a TempDir for a sandbox
func UpdateFixtureFlag ¶
func UpdateFixtureFlag() *bool
UpdateFixtureFlag checks for the -update flag for go test to update the fixtures
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context represents a context of a test loop
func (*Context) DiffString ¶
DiffString is String() for diffs
func (*Context) FieldsString ¶
FieldsString returns the fields of the context as a sorted string of key1=value1 key2=value2 ...
func (*Context) GotExpString ¶
GotExpString is String() for assertions
func (*Context) SetFields ¶
func (context *Context) SetFields(fields ContextFields) *Context
SetFields sets the fields of Context
type ContextFields ¶
type ContextFields map[string]interface{}
ContextFields is the fields of the context