You've already forked opentelemetry-go
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:
@ -89,11 +89,11 @@ func TestUCISetsExpectedServiceNameAttribute(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
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)}
|
exp := &testExporter{make(map[string][]*export.SpanData)}
|
||||||
tp, _ := sdktrace.NewProvider(sdktrace.WithSyncer(exp),
|
tp, _ := sdktrace.NewProvider(sdktrace.WithSyncer(exp),
|
||||||
sdktrace.WithConfig(sdktrace.Config{DefaultSampler: sdktrace.AlwaysSample()}))
|
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())
|
clientConn, err := grpc.Dial("fake:connection", grpc.WithInsecure())
|
||||||
|
|
||||||
if err != nil {
|
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)
|
unaryInt := UnaryClientInterceptor(tr)
|
||||||
@ -117,7 +117,7 @@ func testUCISetsExpectedNameAttribute(t *testing.T, tc nameAttributeTestCase) {
|
|||||||
|
|
||||||
err = unaryInt(ctx, tc.fullName(), req, reply, clientConn, ccInvoker.invoke)
|
err = unaryInt(ctx, tc.fullName(), req, reply, clientConn, ccInvoker.invoke)
|
||||||
if err != nil {
|
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
|
attributes := exp.spanMap[tc.fullName()][0].Attributes
|
||||||
@ -130,7 +130,7 @@ func testUCISetsExpectedNameAttribute(t *testing.T, tc nameAttributeTestCase) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if tc.expectedName != actualServiceName {
|
if tc.expectedName != actualServiceName {
|
||||||
t.Fatalf("[TestCase: %s]: invalid service name found. expected %s, actual %s",
|
t.Fatalf("invalid service name found. expected %s, actual %s",
|
||||||
tc.testName, tc.expectedName, actualServiceName)
|
tc.expectedName, actualServiceName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user