Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NoLeaks ¶
func NoLeaks(t ErrorReporter, wait time.Duration) func()
NoLeaks helps test that a test isn't leaving extra goroutines after it finishes.
The normal way to use it is:
func TestFoo(t *testing.T) { defer goroutines.NoLeaks(t, time.Second)() ... Normal test code here ...
}
The test will fail if there are goroutines running at the end of the test that weren't running at the beginning. Since testing for goroutines being finished can be racy, the detector can wait the specified duration for the set of goroutines to return to the initial set.
Types ¶
type ErrorReporter ¶
type ErrorReporter interface {
Errorf(format string, args ...interface{})
}
ErrorReporter is used by NoLeaks to report errors. testing.T implements this interface and is normally passed.
Click to show internal directories.
Click to hide internal directories.