-
Notifications
You must be signed in to change notification settings - Fork 53
/
tracer_0_14_test.go
78 lines (62 loc) · 2.02 KB
/
tracer_0_14_test.go
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package lightstep_test
import (
"context"
"github.com/lightstep/lightstep-tracer-common/golang/gogo/collectorpb"
"github.com/lightstep/lightstep-tracer-common/golang/gogo/collectorpb/collectorpbfakes"
"github.com/lightstep/lightstep-tracer-go"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/opentracing/opentracing-go"
)
var _ = Describe("Tracerv0_14", func() {
var tracer lightstep.Tracerv0_14
var opts lightstep.Options
const accessToken = "ACCESS_TOKEN"
var fakeClient *collectorpbfakes.FakeCollectorServiceClient
var fakeConn lightstep.ConnectorFactory
var eventHandler lightstep.EventHandler
const eventBufferSize = 10
BeforeEach(func() {
fakeClient = new(collectorpbfakes.FakeCollectorServiceClient)
fakeClient.ReportReturns(&collectorpb.ReportResponse{}, nil)
fakeConn = fakeGrpcConnection(fakeClient)
eventHandler, _ = lightstep.NewEventChannel(eventBufferSize)
lightstep.SetGlobalEventHandler(eventHandler)
})
JustBeforeEach(func() {
opts = lightstep.Options{
AccessToken: accessToken,
ConnFactory: fakeConn,
}
tracer = lightstep.NewTracerv0_14(opts)
})
AfterEach(func() {
closeTestTracer(tracer)
})
Describe("Helper functions", func() {
It("GetLightStepAccessToken returns the access token", func() {
Expect(lightstep.GetLightStepAccessToken(tracer)).To(Equal(accessToken))
})
It("Close closes the tracer", func() {
lightstep.Close(context.Background(), tracer)
})
It("CloseTracer closes the tracer", func() {
err := lightstep.CloseTracer(tracer)
Expect(err).ToNot(HaveOccurred())
})
It("Flush flushes the tracer", func() {
lightstep.Flush(context.Background(), tracer)
})
It("FlushLightStepTracer flushes the tracer", func() {
err := lightstep.FlushLightStepTracer(tracer)
Expect(err).ToNot(HaveOccurred())
})
})
Describe("provides its ReporterID", func() {
It("is non-zero", func() {
rid, err := lightstep.GetLightStepReporterID(opentracing.Tracer(tracer))
Expect(err).To(BeNil())
Expect(rid).To(Not(BeZero()))
})
})
})