1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-07-03 00:27:03 +02:00

use golang table test setup

This commit is contained in:
Stefan Prisca
2020-05-04 10:21:57 +02:00
parent 4ad6e3b73f
commit 75b4d68499

View File

@ -89,11 +89,11 @@ func TestUCISetsExpectedServiceNameAttribute(t *testing.T) {
}
for _, tc := range testCases {
testUCISetsExpectedNameAttribute(t, tc)
t.Run(tc.testName, tc.testUCISetsExpectedNameAttribute)
}
}
func testUCISetsExpectedNameAttribute(t *testing.T, tc nameAttributeTestCase) {
func (tc nameAttributeTestCase) testUCISetsExpectedNameAttribute(t *testing.T) {
exp := &testExporter{make(map[string][]*export.SpanData)}
tp, _ := sdktrace.NewProvider(sdktrace.WithSyncer(exp),
sdktrace.WithConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}))
@ -106,7 +106,7 @@ func testUCISetsExpectedNameAttribute(t *testing.T, tc nameAttributeTestCase) {
clientConn, err := grpc.Dial("fake:connection", grpc.WithInsecure())
if err != nil {
t.Fatalf("[TestCase: %s]: failed to create client connection: %v", tc.testName, err)
t.Fatalf("failed to create client connection: %v", err)
}
unaryInt := UnaryClientInterceptor(tr)
@ -117,7 +117,7 @@ func testUCISetsExpectedNameAttribute(t *testing.T, tc nameAttributeTestCase) {
err = unaryInt(ctx, tc.fullName(), req, reply, clientConn, ccInvoker.invoke)
if err != nil {
t.Fatalf("[TestCase: %s]: failed to run unary interceptor: %v", tc.testName, err)
t.Fatalf("failed to run unary interceptor: %v", err)
}
attributes := exp.spanMap[tc.fullName()][0].Attributes
@ -130,7 +130,7 @@ func testUCISetsExpectedNameAttribute(t *testing.T, tc nameAttributeTestCase) {
}
if tc.expectedName != actualServiceName {
t.Fatalf("[TestCase: %s]: invalid service name found. expected %s, actual %s",
tc.testName, tc.expectedName, actualServiceName)
t.Fatalf("invalid service name found. expected %s, actual %s",
tc.expectedName, actualServiceName)
}
}