-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_test.go
50 lines (38 loc) · 1.05 KB
/
start_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
package tracez
import (
"context"
"path"
"reflect"
"testing"
"github.com/hakadoriya/z.go/otelz/internal/consts"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/noop"
)
func TestStart(t *testing.T) {
t.Parallel()
t.Run("success,", func(t *testing.T) {
ctx := context.WithValue(context.Background(), (*trace.Tracer)(nil), noop.NewTracerProvider().Tracer(consts.TracerName))
ctx, span := Start(ctx)
defer span.End()
if reflect.ValueOf(ctx).IsNil() {
t.Errorf("❌: ctx: expected non-nil, actual nil")
}
})
t.Run("error,", func(t *testing.T) {
ctx := context.Background()
ctx, span := Start(ctx)
defer span.End()
if reflect.ValueOf(ctx).IsNil() {
t.Errorf("❌: ctx: expected non-nil, actual nil")
}
})
}
func Test_fullFuncName(t *testing.T) {
t.Parallel()
if expected, actual := path.Join(consts.ModuleName, "tracez.Test_fullFuncName"), wrapFullFuncName(); actual != expected {
t.Errorf("❌: expected(%q) != actual(%q)", expected, actual)
}
}
func wrapFullFuncName() string {
return fullFuncName(1)
}