apptest

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package apptest provides test helpers for code that depends on the app package. Use New to obtain an App backed by in-memory log and trace recorders so tests run without a live OTLP collector.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New returns an App configured for testing, together with recorders for asserting on logs and spans emitted during the test. The tracer does NOT register itself as the global OTEL provider, ensuring test isolation. The metrics registry is isolated from the process-global default.

a, logRec, spanRec := apptest.New()

ctx, span := a.Tracer().Start(context.Background(), "op")
a.Logger().InfoContext(ctx, "doing work")
span.End()

spans := spanRec.Ended()
assert.Equal(t, "op", spans[0].Name)

records := logRec.Records()
assert.Equal(t, "doing work", records[0].Message)

Types

This section is empty.

Jump to

Keyboard shortcuts

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