chantest

package module
v0.0.0-...-34c9aad Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package chantest implements utilities for testing concurrency.

Index

Constants

View Source
const Default = Before(100 * time.Millisecond)

Default shold be plenty of time for a goroutine to reach a send to a channel if not blocked or doing something slow.

Variables

This section is empty.

Functions

func AssertNoRecv

func AssertNoRecv(t TestingT, ch interface{}, msgAndArgs ...interface{}) interface{}

AssertNoRecv calls Before.AssertNoRecv on Default.

func AssertNoSend

func AssertNoSend(t TestingT, ch, v interface{}, msgAndArgs ...interface{})

AssertNoSend calls Before.AssertNoSend on Default.

func AssertRecv

func AssertRecv(t TestingT, ch interface{}, msgAndArgs ...interface{}) interface{}

AssertRecv calls Before.AssertRecv on Default.

func AssertSend

func AssertSend(t TestingT, ch, v interface{}, msgAndArgs ...interface{})

AssertSend calls Before.AssertSend on Default.

func Expect

func Expect(t TestingT, do func())

Expect calls Before.Expect on Default.

Types

type Before

type Before time.Duration

Before is the amount of time to wait before failing an expectation.

func (Before) AssertNoRecv

func (d Before) AssertNoRecv(t TestingT, ch interface{}, msgAndArgs ...interface{}) interface{}

AssertNoRecv asserts that nothing is received from ch, which must be a channel, for a very short period of time. custom msgAndArgs cand be added, with first argument being the formatted string

func (Before) AssertNoSend

func (d Before) AssertNoSend(t TestingT, ch, v interface{}, msgAndArgs ...interface{})

AssertNoSend asserts that v is not sent to ch, which must be a channel, for a very short period of time. custom msgAndArgs cand be added, with first argument being the formatted string

func (Before) AssertRecv

func (d Before) AssertRecv(t TestingT, ch interface{}, msgAndArgs ...interface{}) interface{}

AssertRecv asserts that something is quickly received from ch, which must be a channel. custom msgAndArgs cand be added, with first argument being the formatted string

func (Before) AssertSend

func (d Before) AssertSend(t TestingT, ch, v interface{}, msgAndArgs ...interface{})

AssertSend asserts that v is quickly sent from ch, which must be a channel. custom msgAndArgs cand be added, with first argument being the formatted string

func (Before) Expect

func (d Before) Expect(t TestingT, do func())

Expect fails the test if do doesn't return very quickly, typically after blocking for a single channel operation.

Useful for testing that a goroutine is unblocked and has reached a certain point that somehow reads or sends to the do function, and to synchronize its continuation with

type TestingT

type TestingT interface {
	Helper()
	Fatal(...interface{})
}

TestingT is an interface wrapper around *testing.T.

Jump to

Keyboard shortcuts

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