test_utils

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

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

func GetFreePortT(t *testing.T) int

GetFreePortT is a wrapper around GetFreePort

func NewTestLogger

func NewTestLogger[T any](t testing.TB, factory func([]io.Writer) T) T

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

func (*TestLogWriter) Write

func (tl *TestLogWriter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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