Documentation
¶
Overview ¶
Package test_utils provides shared test helpers and fixtures for Optimum services.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFreePortT ¶
GetFreePortT is a wrapper around GetFreePort
func NewTestLogger ¶
NewTestLogger wires the TestLogWriter into a repository specific logger factory
Example:
logger := testnetutil.NewTestLogger(t, func(w []io.Writer) logger.AppLogger {
return logger.InitLogger(w, logger.Debug)
})
func RunConcurrently ¶
func RunConcurrently(nGoroutines, nOps int, fn func())
RunConcurrently runs fn from nGoroutines goroutines, nOps times per goroutine, and waits for completion. Useful for stress-testing concurrent access (e.g. RWMap, TTLMap).
Types ¶
type TestLogWriter ¶
type TestLogWriter struct {
// contains filtered or unexported fields
}
TestLogWriter captures slog output during CI runs while mirroring logs to stdout locally
func NewTestLogWriter ¶
func NewTestLogWriter(t testing.TB) *TestLogWriter
NewTestLogWriter creates a writer suitable for wiring into structured loggers in tests Mirrors all output to the provided std writer (stdout by default) during local runs When the CI_RUN environment variable is set, the output is buffered in-memory and printed only if the test fails
func NewTestLogWriterWithOutput ¶
func NewTestLogWriterWithOutput(t testing.TB, std io.Writer) *TestLogWriter
NewTestLogWriterWithOutput behaves like NewTestLogWriter but allows overriding the underlying writer used for local runs