Skip to content

Commit

Permalink
add missed test case
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
  • Loading branch information
codeboten committed May 16, 2024
1 parent 101d558 commit d4cb1c0
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions config/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,25 @@ func TestLogProcessor(t *testing.T) {
},
wantErr: errors.New("no valid log exporter"),
},
{
name: "simple/otlp-exporter",
processor: LogRecordProcessor{
Simple: &SimpleLogRecordProcessor{
Exporter: LogRecordExporter{
OTLP: &OTLP{
Protocol: "http/protobuf",
Endpoint: "localhost:4318",
Compression: ptr("gzip"),
Timeout: ptr(1000),
Headers: map[string]string{
"test": "test1",
},
},
},
},
},
wantProcessor: sdklog.NewSimpleProcessor(otlpHTTPExporter),
},
}
for _, tt := range testCases {
t.Run(tt.name, func(t *testing.T) {
Expand All @@ -327,15 +346,8 @@ func TestLogProcessor(t *testing.T) {
require.Nil(t, got)
} else {
require.Equal(t, reflect.TypeOf(tt.wantProcessor), reflect.TypeOf(got))
var fieldName string
switch reflect.TypeOf(tt.wantProcessor).String() {
case "*log.BatchProcessor":
fieldName = "exporter"
default:
fieldName = "e"
}
wantExporterType := reflect.Indirect(reflect.ValueOf(tt.wantProcessor)).FieldByName(fieldName).Elem().Type()
gotExporterType := reflect.Indirect(reflect.ValueOf(got)).FieldByName(fieldName).Elem().Type()
wantExporterType := reflect.Indirect(reflect.ValueOf(tt.wantProcessor)).FieldByName("exporter").Elem().Type()
gotExporterType := reflect.Indirect(reflect.ValueOf(got)).FieldByName("exporter").Elem().Type()
require.Equal(t, wantExporterType.String(), gotExporterType.String())
}
})
Expand Down

0 comments on commit d4cb1c0

Please sign in to comment.