harness

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Harness

type Harness struct {
	*testing.T
	// contains filtered or unexported fields
}

Harness adds some functionality to testing.T, in particular resource cleanup. It embeds testing.T, so should have the same signature.

Example usage: ```

func MyTest(tt *testing.T) {
  t := harness.For(tt)
  defer t.Close()
  ...
}

```

func For

func For(t *testing.T) *Harness

For creates a Harness from a testing.T Callers must call Close on the Harness so that resources can be cleaned up

func (*Harness) Close

func (h *Harness) Close()

Close cleans up any owned resources, and should be called in a defer block after For

func (*Harness) TempDir

func (h *Harness) TempDir(baseDir string, prefix string) string

TempDir is a wrapper around os.MkdirTemp for tests. It automatically fails the test if we can't create a temp file, and deletes the temp directory when Close is called on the Harness

Jump to

Keyboard shortcuts

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