test

package
v0.0.0-...-a840786 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package test implements some test helpers.

Index

Constants

This section is empty.

Variables

View Source
var ErrTimeout = errors.New("timeout")

ErrTimeout is the error that is returned when something timed out

View Source
var TimeoutDefault = time.Second * 5

TimeoutDefault is the default timeout duration.

Functions

func ChTimeout

func ChTimeout[T any](t *testing.T, ch <-chan T) (T, error)

ChTimeout either returns value from passed channel or zero value of the channel and ErrTimeout

func GoTimeout

func GoTimeout(t *testing.T, fn func() error) error

GoTimeout runs passed function in a go routine and returns ErrTimeout when the function timed out

func GoTimeoutDur

func GoTimeoutDur(t *testing.T, fn func() error, dur time.Duration) error

GoTimeoutDur runs passed function in a go routine and returns ErrTimeout when the function timed out

func NewTestLogger

func NewTestLogger(silent bool) log.Logger

Types

type ErrGroup

type ErrGroup struct {
	errgroup.Group
}

ErrGroup is golang.org/x/sync/errgroup:ErrGroup with extra method(s)

func (*ErrGroup) WaitTimeout

func (g *ErrGroup) WaitTimeout(t *testing.T) error

WaitTimeout waits for the group to finish or error or timeout. Returns ErrTimeout on timeout.

type Log

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

func (*Log) Add

func (l *Log) Add(msg string)

func (*Log) Items

func (l *Log) Items() []string

Jump to

Keyboard shortcuts

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