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 ¶
func New() (*app.App, *logtest.LogRecorder, *tracetest.SpanRecorder)
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.
Click to show internal directories.
Click to hide internal directories.