Documentation
¶
Overview ¶
Package testutil holds test helpers shared across framingo's own packages and usable by apps built on it: a SQLite-backed db.Manager, and doubles for the model interfaces a component receives.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMeterRecorder ¶ added in v0.6.13
func NewMeterRecorder() (*sdkmetric.ManualReader, *sdkmetric.MeterProvider)
NewMeterRecorder pairs a ManualReader with a real SDK provider, so a test creates instruments, records, then Collects and asserts on metricdata - no flush, no sleep, no polling.
func NewRecorder ¶ added in v0.6.12
func NewRecorder() (*tracetest.InMemoryExporter, *sdktrace.TracerProvider)
NewRecorder pairs an in-memory exporter with a synchronous provider, so a span is readable the moment it ends - no flush, no sleep, no polling.
func SetupDB ¶
SetupDB returns an initialized db.Manager backed by an in-memory SQLite database, so a test exercises real SQL rather than a repository double. Requires CGO_ENABLED=1, which the sqlite driver needs.
func SumInt64 ¶ added in v0.6.13
func SumInt64(rm metricdata.ResourceMetrics, name string) (total int64, found bool)
SumInt64 digs the int64 Sum total of the named instrument out of one collected export, summed across data points. found reports whether the instrument appeared with that shape at all - assert on it, so an absent or mistyped metric fails the test instead of reading as zero.
Types ¶
type Meter ¶ added in v0.6.13
type Meter struct {
// contains filtered or unexported fields
}
Meter is a model.Meter serving whatever provider the test supplied. There is deliberately no Swap counterpart to testutil.Tracer's: the production metrics service never replaces its provider, so there is no mid-flight swap for a test to imitate. Pair it with NewMeterRecorder for a real SDK provider whose collected state a test reads back synchronously; a test that just needs some model.Meter is better served by metrics.New(), which serves a real never-exporting provider with no Init, config or exporter.
func NewMeter ¶ added in v0.6.13
func NewMeter(p metric.MeterProvider) *Meter
NewMeter returns a Meter serving p.
func (*Meter) Dependencies ¶ added in v0.6.13
func (*Meter) Provider ¶ added in v0.6.13
func (m *Meter) Provider() metric.MeterProvider
type Tracer ¶ added in v0.6.12
type Tracer struct {
// contains filtered or unexported fields
}
Tracer is a model.Tracer whose provider can be replaced mid-flight, the way a tracing-service restart replaces it in production. The provider it hands out is whatever the test supplied - pair it with NewRecorder for a real SDK provider writing to a real in-memory exporter, so only the service wrapper is a double.
func NewTracer ¶ added in v0.6.12
func NewTracer(p trace.TracerProvider) *Tracer
NewTracer returns a Tracer serving p. Reach for it when a test needs to swap the provider mid-flight, which the real tracing service only does through Init; a test that just needs some model.Tracer is better served by tracing.New(), which serves a noop provider with no Init, config or exporter.
func (*Tracer) Dependencies ¶ added in v0.6.12
func (*Tracer) Propagator ¶ added in v0.6.12
func (t *Tracer) Propagator() propagation.TextMapPropagator
func (*Tracer) Provider ¶ added in v0.6.12
func (t *Tracer) Provider() trace.TracerProvider
func (*Tracer) Swap ¶ added in v0.6.12
func (t *Tracer) Swap(p trace.TracerProvider)
Swap replaces the provider, standing in for a tracing-service restart.