Help us shape the future of Go! Take the 2026 Go Developer Survey

testutil

package
v0.0.0-...-a92561a Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoopbackHost        = netutil.LoopbackHost
	LoopbackDynamicAddr = netutil.LoopbackDynamicAddr
	LoopbackNoProxy     = netutil.LoopbackNoProxy
)

Variables

This section is empty.

Functions

func Eventually

func Eventually(t testing.TB, timeout time.Duration, cond func() bool)

Eventually polls cond until it returns true or timeout elapses, then fails the test. It replaces fixed time.Sleep calls in asynchronous tests, which are the main source of CI flakiness.

func InstallHermeticStorage

func InstallHermeticStorage() (func(), error)

InstallHermeticStorage gives package-level TestMain functions writable, isolated storage without overriding explicit caller configuration. The returned cleanup restores the environment and removes the temporary root.

func IsLoopbackUnavailable

func IsLoopbackUnavailable(err error) bool

func IsolateStorage

func IsolateStorage(t *testing.T) string

IsolateStorage configures isolated HOME and Rho config/state/cache dirs for tests.

func IsolateStorageIn

func IsolateStorageIn(t *testing.T, root string)

IsolateStorageIn configures isolated HOME and Rho config/state/cache dirs rooted at root.

func ListenLoopback

func ListenLoopback(t testing.TB) net.Listener

func Never

func Never(t testing.TB, duration time.Duration, cond func() bool)

Never asserts that cond stays false for the duration, then fails if it ever becomes true. Useful for asserting that a state does not regress.

func NewLoopbackHTTPServer

func NewLoopbackHTTPServer(t testing.TB, handler http.Handler) *httptest.Server

func SkipIfLoopbackUnavailable

func SkipIfLoopbackUnavailable(t testing.TB, err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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