testutils

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsPtr added in v0.3.0

func AsPtr[T any](i T) *T

AsPtr returns the value as a pointer.

func Check

func Check(err error)

Check checks the error and panics if not nil.

func Must

func Must[T any](val T, err error) T

Must checks the error and panics if not nil.

func WithCancel

func WithCancel(d DeferFunc, f func()) (DeferFunc, CancelFunc)

WithCancel returns a deferrable function that can be cancelled.

Types

type CancelFunc

type CancelFunc func()

CancelFunc is a cancel function.

type DeferFunc

type DeferFunc func()

DeferFunc is a deferrable function.

type File added in v0.3.0

type File struct {
	// Path is the path to the file.
	Path string

	// Contents are the file contents.
	Contents []byte

	// Mode is the file permissions mode.
	Mode os.FileMode
}

File is a test file.

type TempDir added in v0.3.0

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

TempDir is a temporary directory which is set up with a directory structure with some files for testing.

func NewTempDir added in v0.3.0

func NewTempDir(files []*File) *TempDir

NewTempDir creates a new TempDir. This creates a new temporary directory and fills it with the files given. Intermediate directories are created automatically with 0700 permissions. This function panics if an error occurs when creating the files.

func (*TempDir) Cleanup added in v0.3.0

func (d *TempDir) Cleanup()

Cleanup deletes the test directory.

func (*TempDir) Dir added in v0.3.0

func (d *TempDir) Dir() string

Dir returns the path to the directory.

Jump to

Keyboard shortcuts

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