Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
  • Loading branch information
pavolloffay committed Aug 18, 2020
1 parent e89fbac commit 5db337f
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions exporter/kafkaexporter/jaeger_marshaller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func TestJaegerMarshaller(t *testing.T) {
require.NotNil(t, jaegerProtoBytes)

jsonMarshaller := &jsonpb.Marshaler{}
jsonBytes := new(bytes.Buffer)
jsonMarshaller.Marshal(jsonBytes, batches[0].Spans[0])
jsonByteBuffer := new(bytes.Buffer)
require.NoError(t, jsonMarshaller.Marshal(jsonByteBuffer, batches[0].Spans[0]))

tests := []struct {
unmarshaller Marshaller
Expand All @@ -67,7 +67,7 @@ func TestJaegerMarshaller(t *testing.T) {
},
},
encoding: "jaeger_json",
messages: []Message{{Value: jsonBytes.Bytes()}},
messages: []Message{{Value: jsonByteBuffer.Bytes()}},
},
}
for _, test := range tests {
Expand All @@ -79,3 +79,17 @@ func TestJaegerMarshaller(t *testing.T) {
})
}
}

func TestJaegerMarshaller_error_covert_traceID(t *testing.T) {
marshaller := jaegerMarshaller{
marshaller: jaegerProtoSpanMarshaller{},
}
td := pdata.NewTraces()
td.ResourceSpans().Resize(1)
td.ResourceSpans().At(0).InstrumentationLibrarySpans().Resize(1)
td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().Resize(1)
// fails in zero traceID
messages, err := marshaller.Marshal(td)
require.Error(t, err)
assert.Nil(t, messages)
}

0 comments on commit 5db337f

Please sign in to comment.