Skip to content

Commit 810232e

Browse files
committed
add another unit test
1 parent 7a267ed commit 810232e

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

exporter/exporterhelper/traces.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ import (
88
"encoding/json"
99
"errors"
1010

11-
"go.uber.org/zap"
12-
1311
"go.opentelemetry.io/otel/trace"
12+
"go.uber.org/zap"
1413

1514
"go.opentelemetry.io/collector/component"
1615
"go.opentelemetry.io/collector/consumer"

exporter/exporterhelper/traces_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,3 +499,18 @@ func TestSerializableToLink(t *testing.T) {
499499
// TraceState will be empty due to error in inserting Member Key "@key"
500500
assert.Equal(t, trace.TraceState{}, res.SpanContext.TraceState())
501501
}
502+
503+
func TestTracesEncoding_Unmarshal_InvalidJSON(t *testing.T) {
504+
// Create invalid JSON bytes
505+
invalidJSON := []byte(`{invalid json}`)
506+
507+
// Create tracesEncoding instance
508+
encoding := tracesEncoding{}
509+
510+
// Attempt to unmarshal invalid JSON
511+
req, err := encoding.Unmarshal(invalidJSON)
512+
513+
// Verify error is returned and request is nil
514+
assert.Error(t, err)
515+
assert.Nil(t, req)
516+
}

0 commit comments

Comments
 (0)