Documentation ¶
Overview ¶
Package oteltest provides functionalities for testing otelsql.
Index ¶
- Variables
- func BackgroundWithSpanContext(traceID trace.TraceID, spanID trace.SpanID) context.Context
- func MustParseSpanID(s string) trace.SpanID
- func MustParseTraceID(s string) trace.TraceID
- type Span
- type SpanAttribute
- type SpanContext
- type Suite
- type SuiteContext
- type SuiteOption
- func MetricsEmpty() SuiteOption
- func MetricsEqualJSON(expect string) SuiteOption
- func MockDatabase(mocks ...func(m sqlmock.Sqlmock)) SuiteOption
- func TracesEmpty() SuiteOption
- func TracesEqualJSON(expect string) SuiteOption
- func TracesMatch(f func(t assert.TestingT, actual []Span) bool) SuiteOption
- func WithMetricsAsserters(fs ...testassert.Func) SuiteOption
- func WithTracesAsserters(fs ...testassert.Func) SuiteOption
Constants ¶
This section is empty.
Variables ¶
var NilSpanID trace.SpanID
NilSpanID is an empty span id.
var NilTraceID trace.TraceID
NilTraceID is an empty trace id.
var SampleSpanID = MustParseSpanID("1d256548fd1a0dba")
SampleSpanID is a sample of span id.
var SampleTraceID = MustParseTraceID("25239e8a2ad5562d561f2ecd6a9744de")
SampleTraceID is a sample of trace id.
Functions ¶
func BackgroundWithSpanContext ¶
BackgroundWithSpanContext creates a new context.Background with trace id and span id.
func MustParseSpanID ¶
MustParseSpanID parse a string to span id.
func MustParseTraceID ¶
MustParseTraceID parse a string to trace id.
Types ¶
type Span ¶
type Span struct { Name string `json:"Name"` SpanContext SpanContext `json:"SpanContext"` Parent SpanContext `json:"Parent"` SpanKind int `json:"SpanKind"` Attributes []SpanAttribute `json:"Attributes"` }
Span represents a span.
type SpanAttribute ¶
type SpanAttribute struct { Key string `json:"Key"` Value struct { Type string `json:"Type"` Value interface{} `json:"Value"` } `json:"Value"` }
SpanAttribute represents a span attribute.
type SpanContext ¶
SpanContext represents a span context.
type Suite ¶
type Suite interface {
Run(t *testing.T, f func(sc SuiteContext))
}
Suite is a test suite.
type SuiteContext ¶
type SuiteContext interface { TracerProvider() trace.TracerProvider MeterProvider() metric.MeterProvider DatabaseDSN() string }
SuiteContext represents a test suite context.
type SuiteOption ¶
type SuiteOption func(c *suiteConfig)
SuiteOption setups the test suite.
func MetricsEqualJSON ¶
func MetricsEqualJSON(expect string) SuiteOption
MetricsEqualJSON sets metrics asserter.
func MockDatabase ¶
func MockDatabase(mocks ...func(m sqlmock.Sqlmock)) SuiteOption
MockDatabase sets sql mockers.
func TracesEqualJSON ¶
func TracesEqualJSON(expect string) SuiteOption
TracesEqualJSON sets traces asserter.
func TracesMatch ¶
func TracesMatch(f func(t assert.TestingT, actual []Span) bool) SuiteOption
TracesMatch asserts traces by a callback.
func WithMetricsAsserters ¶
func WithMetricsAsserters(fs ...testassert.Func) SuiteOption
WithMetricsAsserters sets metrics asserter.
func WithTracesAsserters ¶
func WithTracesAsserters(fs ...testassert.Func) SuiteOption
WithTracesAsserters sets traces asserter.