You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kratos/pkg/net/trace/context_test.go

27 lines
575 B

6 years ago
package trace
import (
"testing"
)
func TestSpanContext(t *testing.T) {
pctx := &spanContext{
6 years ago
ParentID: genID(),
SpanID: genID(),
TraceID: genID(),
Flags: flagSampled,
6 years ago
}
if !pctx.isSampled() {
t.Error("expect sampled")
}
value := pctx.String()
t.Logf("bili-trace-id: %s", value)
pctx2, err := contextFromString(value)
if err != nil {
t.Error(err)
}
6 years ago
if pctx2.ParentID != pctx.ParentID || pctx2.SpanID != pctx.SpanID || pctx2.TraceID != pctx.TraceID || pctx2.Flags != pctx.Flags {
6 years ago
t.Errorf("wrong spancontext get %+v -> %+v", pctx, pctx2)
}
}