Codebase list golang-github-go-kit-kit / ebc4b05
Remove dependency to testify/assert library Daniel Furman 7 years ago
1 changed file(s) with 14 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
11
22 import (
33 "net/http"
4 "reflect"
45 "testing"
56
67 "github.com/opentracing/opentracing-go"
78 "github.com/opentracing/opentracing-go/ext"
89 "github.com/opentracing/opentracing-go/mocktracer"
9 "github.com/stretchr/testify/assert"
1010 "golang.org/x/net/context"
1111
1212 "github.com/go-kit/kit/log"
7373
7474 kitot.ToHTTPRequest(tracer, log.NewNopLogger())(ctx, req)
7575
76 assert.Equal(t, map[string]interface{}{
76 expectedTags := map[string]interface{}{
7777 string(ext.HTTPMethod): "GET",
7878 string(ext.HTTPUrl): "http://test.biz/path",
7979 string(ext.PeerHostname): "test.biz",
80 }, span.Tags())
80 }
81 if !reflect.DeepEqual(expectedTags, span.Tags()) {
82 t.Errorf("Want %q, have %q", expectedTags, span.Tags())
83 }
8184 }
8285
8386 func TestFromHTTPRequestTags(t *testing.T) {
9194 opentracing.SpanFromContext(ctx).Finish()
9295
9396 childSpan := tracer.FinishedSpans()[0]
94 assert.Equal(t, "op", childSpan.OperationName)
95 assert.Equal(t, map[string]interface{}{
97 expectedTags := map[string]interface{}{
9698 string(ext.HTTPMethod): "GET",
9799 string(ext.HTTPUrl): "http://test.biz/path",
98100 string(ext.SpanKind): ext.SpanKindRPCServerEnum,
99 }, childSpan.Tags())
101 }
102 if !reflect.DeepEqual(expectedTags, childSpan.Tags()) {
103 t.Errorf("Want %q, have %q", expectedTags, childSpan.Tags())
104 }
105 if want, have := "op", childSpan.OperationName; want != have {
106 t.Errorf("Want %q, have %q", want, have)
107 }
100108 }