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/util_test.go

22 lines
381 B

6 years ago
package trace
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestFromContext(t *testing.T) {
report := &mockReport{}
5 years ago
t1 := NewTracer("service1", report, true)
6 years ago
sp1 := t1.New("test123")
ctx := context.Background()
ctx = NewContext(ctx, sp1)
sp2, ok := FromContext(ctx)
if !ok {
t.Fatal("nothing from context")
}
assert.Equal(t, sp1, sp2)
}