testing

package
v1.2.16 Latest Latest
Warning

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

Go to latest
Published: May 9, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultChanBufferSize = 1

DefaultChanBufferSize is the default buffer size of the underlying channel.

Variables

This section is empty.

Functions

func EqualError

func EqualError(actual error, expected error, a ...interface{}) (bool, string)

EqualError asserts that a function returned an error (i.e. not `nil`) and that it is equal to the provided error.

func EqualErrorf

func EqualErrorf(actual error, expected error, format string, a ...interface{}) (bool, string)

func Error

func Error(v interface{}, a ...interface{}) (bool, string)

Error asserts that a function returned an error (i.e. not `nil`).

func Errorf

func Errorf(v interface{}, format string, a ...interface{}) (bool, string)

func Nil

func Nil(v interface{}, a ...interface{}) (bool, string)

Nil asserts that the specified object is nil.

func Nilf

func Nilf(v interface{}, format string, a ...interface{}) (bool, string)

func NonError

func NonError(v interface{}, a ...interface{}) (bool, string)

NonError asserts that a function returned a none error (i.e. `nil`).

func NonErrorf

func NonErrorf(v interface{}, format string, a ...interface{}) (bool, string)

func NonNil

func NonNil(v interface{}, a ...interface{}) (bool, string)

NonNil asserts that the specified object is none nil.

func NonNilf

func NonNilf(v interface{}, format string, a ...interface{}) (bool, string)

func NonZero

func NonZero(v interface{}, a ...interface{}) (bool, string)

NonZero asserts that the specified object is none zero.

func NonZerof

func NonZerof(v interface{}, format string, a ...interface{}) (bool, string)

func Zero

func Zero(v interface{}, a ...interface{}) (bool, string)

Zero asserts that the specified object is zero. I.e. nil, "", false, 0 or either a slice or a channel with len == 0.

func Zerof

func Zerof(v interface{}, format string, a ...interface{}) (bool, string)

Types

type Channel

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

Channel wraps a generic channel and provides a timed receive operation.

func NewChannel

func NewChannel() *Channel

NewChannel returns a new Channel.

func NewChannelWithSize

func NewChannelWithSize(bufSize int) *Channel

NewChannelWithSize returns a new Channel with a buffer of bufSize.

func (*Channel) Clear

func (c *Channel) Clear(ctx context.Context) error

Clear drains all values on the underlying channel, or the error returned by ctx if it is closed or cancelled.

func (*Channel) Receive

func (c *Channel) Receive(ctx context.Context) (interface{}, error)

Receive returns the value received on the underlying channel, or the error returned by ctx if it is closed or cancelled.

func (*Channel) ReceiveOrFail

func (c *Channel) ReceiveOrFail() (interface{}, bool)

ReceiveOrFail returns the value on the underlying channel and true, or nil and false if the channel was empty.

func (*Channel) Replace

func (c *Channel) Replace(value interface{})

Replace clears the value on the underlying channel, and sends the new value.

It's expected to be used with a size-1 channel, to only keep the most up-to-date item. This method is inherently racy when invoked concurrently from multiple goroutines.

func (*Channel) Send

func (c *Channel) Send(value interface{})

Send sends value on the underlying channel.

func (*Channel) SendContext

func (c *Channel) SendContext(ctx context.Context, value interface{}) error

SendContext sends value on the underlying channel, or returns an error if the context expires.

func (*Channel) SendOrFail

func (c *Channel) SendOrFail(value interface{}) bool

SendOrFail attempts to send value on the underlying channel. Returns true if successful or false if the channel was full.

Directories

Path Synopsis
Package leakcheck contains functions to check leaked goroutines.
Package leakcheck contains functions to check leaked goroutines.

Jump to

Keyboard shortcuts

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