testutils

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTimeout = time.Second * 30

Functions

func AssertDirExists

func AssertDirExists(t *testing.T, dir string)

func AssertNotPanics

func AssertNotPanics(t *testing.T, f func())

func AssertPanics

func AssertPanics(t *testing.T, f func())

func ContextFromDeadline

func ContextFromDeadline(ctx context.Context, t *testing.T, deadline time.Time) (context.Context, context.CancelFunc)

func ContextFromT

func ContextFromT(ctx context.Context, t *testing.T) (context.Context, context.CancelFunc)

func ContextFromTimeout

func ContextFromTimeout(ctx context.Context, t *testing.T, timeout time.Duration) (context.Context, context.CancelFunc)

func Must

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

Do takes a value of any type and an error. If the error is not nil, it panics with the given error. Otherwise, it returns the value. This function is useful for handling errors that are not expected to occur and can be safely ignored or handled with a panic.

Example:

result := must.Do(someFunction())
// If someFunction() returns an error, the program will panic with that error.
// Otherwise, the result will be assigned the value returned by someFunction().

func MustMkUnixTemp

func MustMkUnixTemp(socketName string) *url.URL

func MustMkdirTemp

func MustMkdirTemp() string

Types

This section is empty.

Jump to

Keyboard shortcuts

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