Skip to content

Commit 7a267ed

Browse files
committed
add unit test
1 parent 01997b2 commit 7a267ed

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

exporter/exporterhelper/traces_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,3 +477,25 @@ func checkWrapSpanForTraces(t *testing.T, sr *tracetest.SpanRecorder, tracer tra
477477
require.Containsf(t, sd.Attributes(), attribute.KeyValue{Key: internal.ItemsFailed, Value: attribute.Int64Value(failedToSendSpans)}, "SpanData %v", sd)
478478
}
479479
}
480+
481+
func TestSerializableToLink(t *testing.T) {
482+
sl := SerializableLink{
483+
TraceID: [16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
484+
SpanID: [8]byte{1, 2, 3, 4, 5, 6, 7, 8},
485+
TraceFlags: byte(trace.FlagsSampled),
486+
TraceState: TraceStateSerializable{
487+
Members: []struct {
488+
Key string `json:"key"`
489+
Value string `json:"value"`
490+
}{
491+
{
492+
Key: "@key", // @ is not allowed in trace state keys
493+
Value: "value",
494+
},
495+
},
496+
},
497+
}
498+
res := serializableToLink(sl)
499+
// TraceState will be empty due to error in inserting Member Key "@key"
500+
assert.Equal(t, trace.TraceState{}, res.SpanContext.TraceState())
501+
}

0 commit comments

Comments
 (0)