summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/tracing/tracerprovider_test.go
blob: cb2e5936f9af5c5fb6b3b38fca03ca7ea2ce44d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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")
	}
}