Documentation
¶
Index ¶
- func New(t Cleaner) context.Context
- func SetDefaultTimeout(t time.Duration)
- func WithBackground(t Cleaner) context.Context
- func WithCancel(t Cleaner) (context.Context, func())
- func WithParent(t Cleaner, parent context.Context) context.Context
- func WithTimeout(t Cleaner, timeout time.Duration) context.Context
- type Cleaner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New returns a new context that times out at the default timeout and is canceled once the test is done.
func SetDefaultTimeout ¶
SetDefaultTimeout sets the default timeout duration for new contexts at the package level. While this is safe for concurrent access, it is usually an error to use different timeout values for different tests of the same package as it can lead to data races. If a particular test or operation requires a different timeout value, it is better to call WithTimeout and use the returned context explicitly.
func WithBackground ¶ added in v0.2.0
WithBackground returns a new context that uses context.Background() as parent (thus disabling the standard timeout generated by this package).
func WithCancel ¶
WithCancel returns a new context with the default timeout value and a cancel function that can be used for early termination.
func WithParent ¶
WithParent returns a new context with the specified parent that times out at the default timeout value.