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.
21 lines
405 B
21 lines
405 B
package trace |
|
|
|
import ( |
|
"context" |
|
"testing" |
|
|
|
"github.com/stretchr/testify/assert" |
|
) |
|
|
|
func TestFromContext(t *testing.T) { |
|
report := &mockReport{} |
|
t1 := newTracer("service1", report, &Config{DisableSample: true}) |
|
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) |
|
}
|
|
|