mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-15 00:09:53 +08:00
43 lines
809 B
Go
43 lines
809 B
Go
package tracing
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func Test_tracersProvider_getTracerProvider(t *testing.T) {
|
|
tp := tracerProvider{}
|
|
|
|
tp.getTracerProvider()
|
|
tp.getTracerProvider()
|
|
|
|
if tp.tracerProvider == nil {
|
|
t.Errorf("There should be tracer provider")
|
|
}
|
|
|
|
if tp.tracerProvidersCounter != 2 {
|
|
t.Errorf("Tracer providers counter should equal to 2")
|
|
}
|
|
}
|
|
|
|
func Test_tracersProvider_cleanupTracerProvider(t *testing.T) {
|
|
tp := tracerProvider{}
|
|
|
|
tp.getTracerProvider()
|
|
tp.getTracerProvider()
|
|
|
|
err := tp.cleanupTracerProvider(zap.NewNop())
|
|
if err != nil {
|
|
t.Errorf("There should be no error: %v", err)
|
|
}
|
|
|
|
if tp.tracerProvider == nil {
|
|
t.Errorf("There should be tracer provider")
|
|
}
|
|
|
|
if tp.tracerProvidersCounter != 1 {
|
|
t.Errorf("Tracer providers counter should equal to 1")
|
|
}
|
|
}
|