File: endpoint_test.go

package info (click to toggle)
golang-github-go-kit-kit 0.13.0-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,784 kB
  • sloc: sh: 22; makefile: 11
file content (31 lines) | stat: -rw-r--r-- 721 bytes parent folder | download | duplicates (3)
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
27
28
29
30
31
package zipkin_test

import (
	"context"
	"testing"

	"github.com/openzipkin/zipkin-go"
	"github.com/openzipkin/zipkin-go/reporter/recorder"

	"github.com/go-kit/kit/endpoint"
	zipkinkit "github.com/go-kit/kit/tracing/zipkin"
)

const spanName = "test"

func TestTraceEndpoint(t *testing.T) {
	rec := recorder.NewReporter()
	tr, _ := zipkin.NewTracer(rec)
	mw := zipkinkit.TraceEndpoint(tr, spanName)
	mw(endpoint.Nop)(context.Background(), nil)

	spans := rec.Flush()

	if want, have := 1, len(spans); want != have {
		t.Fatalf("incorrect number of spans, wanted %d, got %d", want, have)
	}

	if want, have := spanName, spans[0].Name; want != have {
		t.Fatalf("incorrect span name, wanted %s, got %s", want, have)
	}
}