Documentation
¶
Overview ¶
Package leakcheck provides test-time helpers for detecting resource leaks: file descriptors, docker containers, and (via go.uber.org/goleak wired at the TestMain level) goroutines.
Usage in a test:
func TestSomething(t *testing.T) {
defer leakcheck.FDCheck(t)()
// test body
}
The returned closure records the baseline and, when deferred, compares to the current count. A small slack (2 by default) accommodates buffered log writes and is configurable via FDCheckN.
DockerContainerCheck compares the count of containers matching a label filter before/after the test, catching runaway container leaks from docker-based runners.
All functions are safe no-ops on platforms where the underlying probe is unavailable; they log a diagnostic rather than failing the test.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DockerContainerCheck ¶
DockerContainerCheck returns a deferred checker that verifies no new containers matching filter are left running by the test. filter is a docker ps --filter expression, e.g. "label=test-codefly=true" or "name=codefly-test-".
If docker is unavailable, the check is skipped with a log line.
Types ¶
This section is empty.