testutil

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Setenv

func Setenv(t TestingT, k, v string)

Setenv changes an environment variable's value for the duration of the current test.

It automatically restores the previous value, if any, after the test finishes.

func TempDir

func TempDir(t TestingT) string

TempDir creates a new temporary directory inside the current test context.

It deletes the directory when the test finishes.

func Unsetenv

func Unsetenv(t TestingT, k string)

Unsetenv unsets the given environment variable for the duration of the current test.

It automatically restores the previous value, if any, after the test finishes.

Types

type TestingT

type TestingT interface {
	Name() string

	Helper()

	Logf(string, ...interface{})
	Errorf(string, ...interface{})
	Fatalf(string, ...interface{})

	Cleanup(func())
}

TestingT is a subset of the testing.T interface.

type Writer

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

Writer writes output to the given TestingT.

func NewWriter

func NewWriter(t TestingT) *Writer

NewWriter builds a new test Writer.

func (*Writer) Write

func (w *Writer) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

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