Documentation
¶
Overview ¶
Package chantest implements utilities for testing concurrency.
Index ¶
- Constants
- func AssertNoRecv(t TestingT, ch interface{}, msgAndArgs ...interface{}) interface{}
- func AssertNoSend(t TestingT, ch, v interface{}, msgAndArgs ...interface{})
- func AssertRecv(t TestingT, ch interface{}, msgAndArgs ...interface{}) interface{}
- func AssertSend(t TestingT, ch, v interface{}, msgAndArgs ...interface{})
- func Expect(t TestingT, do func())
- type Before
- func (d Before) AssertNoRecv(t TestingT, ch interface{}, msgAndArgs ...interface{}) interface{}
- func (d Before) AssertNoSend(t TestingT, ch, v interface{}, msgAndArgs ...interface{})
- func (d Before) AssertRecv(t TestingT, ch interface{}, msgAndArgs ...interface{}) interface{}
- func (d Before) AssertSend(t TestingT, ch, v interface{}, msgAndArgs ...interface{})
- func (d Before) Expect(t TestingT, do func())
- type TestingT
Constants ¶
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.
Types ¶
type Before ¶
Before is the amount of time to wait before failing an expectation.
func (Before) AssertNoRecv ¶
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 ¶
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 ¶
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 ¶
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 ¶
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