testutil

package
v0.1.0-rc.8 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package testutil provides test-only helpers for integration scenarios and OpenTelemetry assertions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequireNetworkIntegration

func RequireNetworkIntegration(t testing.TB)

RequireNetworkIntegration marks the test as a network integration scenario and skips it unless the dedicated env flag is enabled.

func WriteArtifact

func WriteArtifact(t testing.TB, name string, content []byte)

WriteArtifact stores a test artifact when the current Go version exposes ArtifactDir.

Types

type OTelRecorder

type OTelRecorder struct {
	// contains filtered or unexported fields
}

OTelRecorder captures OpenTelemetry spans and logs for assertion in tests.

func InstallOTelRecorder

func InstallOTelRecorder(t testing.TB) *OTelRecorder

InstallOTelRecorder sets up a global OpenTelemetry recorder for the duration of the test. It replaces the global tracer and logger providers and restores them during test cleanup.

func (*OTelRecorder) FindLog

func (r *OTelRecorder) FindLog(body string) (RecordedLog, bool)

FindLog searches for a captured log by its body content.

func (*OTelRecorder) FindSpan

func (r *OTelRecorder) FindSpan(name string) (RecordedSpan, bool)

FindSpan searches for a captured span by name.

type RecordedLog

type RecordedLog struct {
	Body    string
	TraceID trace.TraceID
	SpanID  trace.SpanID
}

RecordedLog represents a log entry captured during testing.

type RecordedSpan

type RecordedSpan struct {
	Name       string
	TraceID    trace.TraceID
	SpanID     trace.SpanID
	ParentSpan trace.SpanID
}

RecordedSpan represents a span captured during testing.

Jump to

Keyboard shortcuts

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