-
Notifications
You must be signed in to change notification settings - Fork 1
/
log_test.go
26 lines (24 loc) · 929 Bytes
/
log_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
package crzerolog
import (
"testing"
)
func TestTraceContextFromHeader(t *testing.T) {
for _, tt := range []struct {
header string
wantTraceID string
wantSpanID string
}{
{"0123456789abcdef0123456789abcdef/123;o=1", "0123456789abcdef0123456789abcdef", "000000000000007b"},
{"0123456789abcdef0123456789abcdef/123;o=0", "0123456789abcdef0123456789abcdef", "000000000000007b"},
{"0123456789abcdef0123456789abcdef/123", "0123456789abcdef0123456789abcdef", "000000000000007b"},
{"0123456789abcdef0123456789abcdef", "0123456789abcdef0123456789abcdef", ""},
{"0123456789abcdef0123456789abcdef/invalid", "", ""},
{"invalid", "", ""},
{"", "", ""},
} {
traceID, spanID := traceContextFromHeader(tt.header)
if traceID != tt.wantTraceID || spanID != tt.wantSpanID {
t.Errorf("traceContextFromHeader(%q) = (%q, %q), want = (%q, %q)", tt.header, traceID, spanID, tt.wantTraceID, tt.wantSpanID)
}
}
}