From e690ac5b96cbc619a0316a75db951c95247aa9ae Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Thu, 7 Nov 2024 11:52:11 -0800 Subject: [PATCH] [chore] Simplify test only code in exporterhelper (#11620) Signed-off-by: Bogdan Drutu --- .../exporterhelperprofiles/profiles_test.go | 20 ++++++------ exporter/exporterhelper/internal/request.go | 32 +++++++++---------- exporter/exporterhelper/logs_test.go | 24 +++++++------- exporter/exporterhelper/metrics_test.go | 24 +++++++------- exporter/exporterhelper/traces_test.go | 24 +++++++------- 5 files changed, 66 insertions(+), 58 deletions(-) diff --git a/exporter/exporterhelper/exporterhelperprofiles/profiles_test.go b/exporter/exporterhelper/exporterhelperprofiles/profiles_test.go index 6422cc81f9a..3c7d74efab2 100644 --- a/exporter/exporterhelper/exporterhelperprofiles/profiles_test.go +++ b/exporter/exporterhelper/exporterhelperprofiles/profiles_test.go @@ -68,7 +68,7 @@ func TestProfilesExporter_NilLogger(t *testing.T) { } func TestProfilesRequestExporter_NilLogger(t *testing.T) { - le, err := NewProfilesRequestExporter(context.Background(), exporter.Settings{}, (&internal.FakeRequestConverter{}).RequestFromProfilesFunc) + le, err := NewProfilesRequestExporter(context.Background(), exporter.Settings{}, internal.RequestFromProfilesFunc(nil)) require.Nil(t, le) require.Equal(t, errNilLogger, err) } @@ -100,7 +100,7 @@ func TestProfilesExporter_Default(t *testing.T) { func TestProfilesRequestExporter_Default(t *testing.T) { ld := pprofile.NewProfiles() le, err := NewProfilesRequestExporter(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{}).RequestFromProfilesFunc) + internal.RequestFromProfilesFunc(nil)) assert.NotNil(t, le) require.NoError(t, err) @@ -122,7 +122,7 @@ func TestProfilesExporter_WithCapabilities(t *testing.T) { func TestProfilesRequestExporter_WithCapabilities(t *testing.T) { capabilities := consumer.Capabilities{MutatesData: true} le, err := NewProfilesRequestExporter(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{}).RequestFromProfilesFunc, exporterhelper.WithCapabilities(capabilities)) + internal.RequestFromProfilesFunc(nil), exporterhelper.WithCapabilities(capabilities)) require.NoError(t, err) require.NotNil(t, le) @@ -142,7 +142,9 @@ func TestProfilesRequestExporter_Default_ConvertError(t *testing.T) { ld := pprofile.NewProfiles() want := errors.New("convert_error") le, err := NewProfilesRequestExporter(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{ProfilesError: want}).RequestFromProfilesFunc) + func(context.Context, pprofile.Profiles) (exporterhelper.Request, error) { + return nil, want + }) require.NoError(t, err) require.NotNil(t, le) require.Equal(t, consumererror.NewPermanent(want), le.ConsumeProfiles(context.Background(), ld)) @@ -152,7 +154,7 @@ func TestProfilesRequestExporter_Default_ExportError(t *testing.T) { ld := pprofile.NewProfiles() want := errors.New("export_error") le, err := NewProfilesRequestExporter(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{RequestError: want}).RequestFromProfilesFunc) + internal.RequestFromProfilesFunc(want)) require.NoError(t, err) require.NotNil(t, le) require.Equal(t, want, le.ConsumeProfiles(context.Background(), ld)) @@ -202,7 +204,7 @@ func TestProfilesRequestExporter_WithSpan(t *testing.T) { otel.SetTracerProvider(set.TracerProvider) defer otel.SetTracerProvider(nooptrace.NewTracerProvider()) - le, err := NewProfilesRequestExporter(context.Background(), set, (&internal.FakeRequestConverter{}).RequestFromProfilesFunc) + le, err := NewProfilesRequestExporter(context.Background(), set, internal.RequestFromProfilesFunc(nil)) require.NoError(t, err) require.NotNil(t, le) checkWrapSpanForProfilesExporter(t, sr, set.TracerProvider.Tracer("test"), le, nil, 1) @@ -230,7 +232,7 @@ func TestProfilesRequestExporter_WithSpan_ReturnError(t *testing.T) { defer otel.SetTracerProvider(nooptrace.NewTracerProvider()) want := errors.New("my_error") - le, err := NewProfilesRequestExporter(context.Background(), set, (&internal.FakeRequestConverter{RequestError: want}).RequestFromProfilesFunc) + le, err := NewProfilesRequestExporter(context.Background(), set, internal.RequestFromProfilesFunc(want)) require.NoError(t, err) require.NotNil(t, le) checkWrapSpanForProfilesExporter(t, sr, set.TracerProvider.Tracer("test"), le, want, 1) @@ -253,7 +255,7 @@ func TestProfilesRequestExporter_WithShutdown(t *testing.T) { shutdown := func(context.Context) error { shutdownCalled = true; return nil } le, err := NewProfilesRequestExporter(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{}).RequestFromProfilesFunc, exporterhelper.WithShutdown(shutdown)) + internal.RequestFromProfilesFunc(nil), exporterhelper.WithShutdown(shutdown)) assert.NotNil(t, le) require.NoError(t, err) @@ -277,7 +279,7 @@ func TestProfilesRequestExporter_WithShutdown_ReturnError(t *testing.T) { shutdownErr := func(context.Context) error { return want } le, err := NewProfilesRequestExporter(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{}).RequestFromProfilesFunc, exporterhelper.WithShutdown(shutdownErr)) + internal.RequestFromProfilesFunc(nil), exporterhelper.WithShutdown(shutdownErr)) assert.NotNil(t, le) require.NoError(t, err) diff --git a/exporter/exporterhelper/internal/request.go b/exporter/exporterhelper/internal/request.go index 7f71d7e94ea..87952c1e8f3 100644 --- a/exporter/exporterhelper/internal/request.go +++ b/exporter/exporterhelper/internal/request.go @@ -125,26 +125,26 @@ func (r *fakeRequest) MergeSplit(ctx context.Context, cfg exporterbatcher.MaxSiz return res, nil } -type FakeRequestConverter struct { - MetricsError error - TracesError error - LogsError error - ProfilesError error - RequestError error -} - -func (frc *FakeRequestConverter) RequestFromMetricsFunc(_ context.Context, md pmetric.Metrics) (internal.Request, error) { - return &fakeRequest{items: md.DataPointCount(), exportErr: frc.RequestError}, frc.MetricsError +func RequestFromMetricsFunc(reqErr error) func(context.Context, pmetric.Metrics) (internal.Request, error) { + return func(_ context.Context, md pmetric.Metrics) (internal.Request, error) { + return &fakeRequest{items: md.DataPointCount(), exportErr: reqErr}, nil + } } -func (frc *FakeRequestConverter) RequestFromTracesFunc(_ context.Context, md ptrace.Traces) (internal.Request, error) { - return &fakeRequest{items: md.SpanCount(), exportErr: frc.RequestError}, frc.TracesError +func RequestFromTracesFunc(reqErr error) func(context.Context, ptrace.Traces) (internal.Request, error) { + return func(_ context.Context, td ptrace.Traces) (internal.Request, error) { + return &fakeRequest{items: td.SpanCount(), exportErr: reqErr}, nil + } } -func (frc *FakeRequestConverter) RequestFromLogsFunc(_ context.Context, md plog.Logs) (internal.Request, error) { - return &fakeRequest{items: md.LogRecordCount(), exportErr: frc.RequestError}, frc.LogsError +func RequestFromLogsFunc(reqErr error) func(context.Context, plog.Logs) (internal.Request, error) { + return func(_ context.Context, ld plog.Logs) (internal.Request, error) { + return &fakeRequest{items: ld.LogRecordCount(), exportErr: reqErr}, nil + } } -func (frc *FakeRequestConverter) RequestFromProfilesFunc(_ context.Context, md pprofile.Profiles) (internal.Request, error) { - return &fakeRequest{items: md.SampleCount(), exportErr: frc.RequestError}, frc.ProfilesError +func RequestFromProfilesFunc(reqErr error) func(context.Context, pprofile.Profiles) (internal.Request, error) { + return func(_ context.Context, pd pprofile.Profiles) (internal.Request, error) { + return &fakeRequest{items: pd.SampleCount(), exportErr: reqErr}, nil + } } diff --git a/exporter/exporterhelper/logs_test.go b/exporter/exporterhelper/logs_test.go index 52d6ffca605..6b565fafbd8 100644 --- a/exporter/exporterhelper/logs_test.go +++ b/exporter/exporterhelper/logs_test.go @@ -65,7 +65,7 @@ func TestLogs_NilLogger(t *testing.T) { } func TestLogsRequest_NilLogger(t *testing.T) { - le, err := NewLogsRequest(context.Background(), exporter.Settings{}, (&internal.FakeRequestConverter{}).RequestFromLogsFunc) + le, err := NewLogsRequest(context.Background(), exporter.Settings{}, internal.RequestFromLogsFunc(nil)) require.Nil(t, le) require.Equal(t, errNilLogger, err) } @@ -97,7 +97,7 @@ func TestLogs_Default(t *testing.T) { func TestLogsRequest_Default(t *testing.T) { ld := plog.NewLogs() le, err := NewLogsRequest(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{}).RequestFromLogsFunc) + internal.RequestFromLogsFunc(nil)) assert.NotNil(t, le) require.NoError(t, err) @@ -119,7 +119,7 @@ func TestLogs_WithCapabilities(t *testing.T) { func TestLogsRequest_WithCapabilities(t *testing.T) { capabilities := consumer.Capabilities{MutatesData: true} le, err := NewLogsRequest(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{}).RequestFromLogsFunc, WithCapabilities(capabilities)) + internal.RequestFromLogsFunc(nil), WithCapabilities(capabilities)) require.NoError(t, err) require.NotNil(t, le) @@ -139,7 +139,9 @@ func TestLogsRequest_Default_ConvertError(t *testing.T) { ld := plog.NewLogs() want := errors.New("convert_error") le, err := NewLogsRequest(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{LogsError: want}).RequestFromLogsFunc) + func(context.Context, plog.Logs) (Request, error) { + return nil, want + }) require.NoError(t, err) require.NotNil(t, le) require.Equal(t, consumererror.NewPermanent(want), le.ConsumeLogs(context.Background(), ld)) @@ -149,7 +151,7 @@ func TestLogsRequest_Default_ExportError(t *testing.T) { ld := plog.NewLogs() want := errors.New("export_error") le, err := NewLogsRequest(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{RequestError: want}).RequestFromLogsFunc) + internal.RequestFromLogsFunc(want)) require.NoError(t, err) require.NotNil(t, le) require.Equal(t, want, le.ConsumeLogs(context.Background(), ld)) @@ -213,7 +215,7 @@ func TestLogsRequest_WithRecordMetrics(t *testing.T) { le, err := NewLogsRequest(context.Background(), exporter.Settings{ID: fakeLogsName, TelemetrySettings: tt.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()}, - (&internal.FakeRequestConverter{}).RequestFromLogsFunc) + internal.RequestFromLogsFunc(nil)) require.NoError(t, err) require.NotNil(t, le) @@ -240,7 +242,7 @@ func TestLogsRequest_WithRecordMetrics_ExportError(t *testing.T) { t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) }) le, err := NewLogsRequest(context.Background(), exporter.Settings{ID: fakeLogsName, TelemetrySettings: tt.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()}, - (&internal.FakeRequestConverter{RequestError: want}).RequestFromLogsFunc) + internal.RequestFromLogsFunc(want)) require.NoError(t, err) require.NotNil(t, le) @@ -292,7 +294,7 @@ func TestLogsRequest_WithSpan(t *testing.T) { otel.SetTracerProvider(set.TracerProvider) defer otel.SetTracerProvider(nooptrace.NewTracerProvider()) - le, err := NewLogsRequest(context.Background(), set, (&internal.FakeRequestConverter{}).RequestFromLogsFunc) + le, err := NewLogsRequest(context.Background(), set, internal.RequestFromLogsFunc(nil)) require.NoError(t, err) require.NotNil(t, le) checkWrapSpanForLogs(t, sr, set.TracerProvider.Tracer("test"), le, nil, 1) @@ -320,7 +322,7 @@ func TestLogsRequest_WithSpan_ReturnError(t *testing.T) { defer otel.SetTracerProvider(nooptrace.NewTracerProvider()) want := errors.New("my_error") - le, err := NewLogsRequest(context.Background(), set, (&internal.FakeRequestConverter{RequestError: want}).RequestFromLogsFunc) + le, err := NewLogsRequest(context.Background(), set, internal.RequestFromLogsFunc(want)) require.NoError(t, err) require.NotNil(t, le) checkWrapSpanForLogs(t, sr, set.TracerProvider.Tracer("test"), le, want, 1) @@ -343,7 +345,7 @@ func TestLogsRequest_WithShutdown(t *testing.T) { shutdown := func(context.Context) error { shutdownCalled = true; return nil } le, err := NewLogsRequest(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{}).RequestFromLogsFunc, WithShutdown(shutdown)) + internal.RequestFromLogsFunc(nil), WithShutdown(shutdown)) assert.NotNil(t, le) assert.NoError(t, err) @@ -367,7 +369,7 @@ func TestLogsRequest_WithShutdown_ReturnError(t *testing.T) { shutdownErr := func(context.Context) error { return want } le, err := NewLogsRequest(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{}).RequestFromLogsFunc, WithShutdown(shutdownErr)) + internal.RequestFromLogsFunc(nil), WithShutdown(shutdownErr)) assert.NotNil(t, le) require.NoError(t, err) diff --git a/exporter/exporterhelper/metrics_test.go b/exporter/exporterhelper/metrics_test.go index f239a05fea5..5d89c3bee63 100644 --- a/exporter/exporterhelper/metrics_test.go +++ b/exporter/exporterhelper/metrics_test.go @@ -66,7 +66,7 @@ func TestMetrics_NilLogger(t *testing.T) { func TestMetricsRequest_NilLogger(t *testing.T) { me, err := NewMetricsRequest(context.Background(), exporter.Settings{}, - (&internal.FakeRequestConverter{}).RequestFromMetricsFunc) + internal.RequestFromMetricsFunc(nil)) require.Nil(t, me) require.Equal(t, errNilLogger, err) } @@ -98,7 +98,7 @@ func TestMetrics_Default(t *testing.T) { func TestMetricsRequest_Default(t *testing.T) { md := pmetric.NewMetrics() me, err := NewMetricsRequest(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{}).RequestFromMetricsFunc) + internal.RequestFromMetricsFunc(nil)) require.NoError(t, err) assert.NotNil(t, me) @@ -120,7 +120,7 @@ func TestMetrics_WithCapabilities(t *testing.T) { func TestMetricsRequest_WithCapabilities(t *testing.T) { capabilities := consumer.Capabilities{MutatesData: true} me, err := NewMetricsRequest(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{}).RequestFromMetricsFunc, WithCapabilities(capabilities)) + internal.RequestFromMetricsFunc(nil), WithCapabilities(capabilities)) require.NoError(t, err) assert.NotNil(t, me) @@ -140,7 +140,9 @@ func TestMetricsRequest_Default_ConvertError(t *testing.T) { md := pmetric.NewMetrics() want := errors.New("convert_error") me, err := NewMetricsRequest(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{MetricsError: want}).RequestFromMetricsFunc) + func(context.Context, pmetric.Metrics) (Request, error) { + return nil, want + }) require.NoError(t, err) require.NotNil(t, me) require.Equal(t, consumererror.NewPermanent(want), me.ConsumeMetrics(context.Background(), md)) @@ -150,7 +152,7 @@ func TestMetricsRequest_Default_ExportError(t *testing.T) { md := pmetric.NewMetrics() want := errors.New("export_error") me, err := NewMetricsRequest(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{RequestError: want}).RequestFromMetricsFunc) + internal.RequestFromMetricsFunc(want)) require.NoError(t, err) require.NotNil(t, me) require.Equal(t, want, me.ConsumeMetrics(context.Background(), md)) @@ -214,7 +216,7 @@ func TestMetricsRequest_WithRecordMetrics(t *testing.T) { me, err := NewMetricsRequest(context.Background(), exporter.Settings{ID: fakeMetricsName, TelemetrySettings: tt.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()}, - (&internal.FakeRequestConverter{}).RequestFromMetricsFunc) + internal.RequestFromMetricsFunc(nil)) require.NoError(t, err) require.NotNil(t, me) @@ -242,7 +244,7 @@ func TestMetricsRequest_WithRecordMetrics_ExportError(t *testing.T) { me, err := NewMetricsRequest(context.Background(), exporter.Settings{ID: fakeMetricsName, TelemetrySettings: tt.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()}, - (&internal.FakeRequestConverter{RequestError: want}).RequestFromMetricsFunc) + internal.RequestFromMetricsFunc(want)) require.NoError(t, err) require.NotNil(t, me) @@ -294,7 +296,7 @@ func TestMetricsRequest_WithSpan(t *testing.T) { otel.SetTracerProvider(set.TracerProvider) defer otel.SetTracerProvider(nooptrace.NewTracerProvider()) - me, err := NewMetricsRequest(context.Background(), set, (&internal.FakeRequestConverter{}).RequestFromMetricsFunc) + me, err := NewMetricsRequest(context.Background(), set, internal.RequestFromMetricsFunc(nil)) require.NoError(t, err) require.NotNil(t, me) checkWrapSpanForMetrics(t, sr, set.TracerProvider.Tracer("test"), me, nil, 2) @@ -322,7 +324,7 @@ func TestMetricsRequest_WithSpan_ExportError(t *testing.T) { defer otel.SetTracerProvider(nooptrace.NewTracerProvider()) want := errors.New("my_error") - me, err := NewMetricsRequest(context.Background(), set, (&internal.FakeRequestConverter{RequestError: want}).RequestFromMetricsFunc) + me, err := NewMetricsRequest(context.Background(), set, internal.RequestFromMetricsFunc(want)) require.NoError(t, err) require.NotNil(t, me) checkWrapSpanForMetrics(t, sr, set.TracerProvider.Tracer("test"), me, want, 2) @@ -346,7 +348,7 @@ func TestMetricsRequest_WithShutdown(t *testing.T) { shutdown := func(context.Context) error { shutdownCalled = true; return nil } me, err := NewMetricsRequest(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{}).RequestFromMetricsFunc, WithShutdown(shutdown)) + internal.RequestFromMetricsFunc(nil), WithShutdown(shutdown)) assert.NotNil(t, me) assert.NoError(t, err) @@ -372,7 +374,7 @@ func TestMetricsRequest_WithShutdown_ReturnError(t *testing.T) { shutdownErr := func(context.Context) error { return want } me, err := NewMetricsRequest(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{}).RequestFromMetricsFunc, WithShutdown(shutdownErr)) + internal.RequestFromMetricsFunc(nil), WithShutdown(shutdownErr)) assert.NotNil(t, me) assert.NoError(t, err) diff --git a/exporter/exporterhelper/traces_test.go b/exporter/exporterhelper/traces_test.go index 54cde596b36..7b22e8dbbf3 100644 --- a/exporter/exporterhelper/traces_test.go +++ b/exporter/exporterhelper/traces_test.go @@ -61,7 +61,7 @@ func TestTraces_NilLogger(t *testing.T) { } func TestTracesRequest_NilLogger(t *testing.T) { - te, err := NewTracesRequest(context.Background(), exporter.Settings{}, (&internal.FakeRequestConverter{}).RequestFromTracesFunc) + te, err := NewTracesRequest(context.Background(), exporter.Settings{}, internal.RequestFromTracesFunc(nil)) require.Nil(t, te) require.Equal(t, errNilLogger, err) } @@ -93,7 +93,7 @@ func TestTraces_Default(t *testing.T) { func TestTracesRequest_Default(t *testing.T) { td := ptrace.NewTraces() te, err := NewTracesRequest(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{}).RequestFromTracesFunc) + internal.RequestFromTracesFunc(nil)) assert.NotNil(t, te) require.NoError(t, err) @@ -115,7 +115,7 @@ func TestTraces_WithCapabilities(t *testing.T) { func TestTracesRequest_WithCapabilities(t *testing.T) { capabilities := consumer.Capabilities{MutatesData: true} te, err := NewTracesRequest(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{}).RequestFromTracesFunc, WithCapabilities(capabilities)) + internal.RequestFromTracesFunc(nil), WithCapabilities(capabilities)) assert.NotNil(t, te) require.NoError(t, err) @@ -137,7 +137,9 @@ func TestTracesRequest_Default_ConvertError(t *testing.T) { td := ptrace.NewTraces() want := errors.New("convert_error") te, err := NewTracesRequest(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{TracesError: want}).RequestFromTracesFunc) + func(context.Context, ptrace.Traces) (Request, error) { + return nil, want + }) require.NoError(t, err) require.NotNil(t, te) require.Equal(t, consumererror.NewPermanent(want), te.ConsumeTraces(context.Background(), td)) @@ -147,7 +149,7 @@ func TestTracesRequest_Default_ExportError(t *testing.T) { td := ptrace.NewTraces() want := errors.New("export_error") te, err := NewTracesRequest(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{RequestError: want}).RequestFromTracesFunc) + internal.RequestFromTracesFunc(want)) require.NoError(t, err) require.NotNil(t, te) require.Equal(t, want, te.ConsumeTraces(context.Background(), td)) @@ -211,7 +213,7 @@ func TestTracesRequest_WithRecordMetrics(t *testing.T) { te, err := NewTracesRequest(context.Background(), exporter.Settings{ID: fakeTracesName, TelemetrySettings: tt.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()}, - (&internal.FakeRequestConverter{}).RequestFromTracesFunc) + internal.RequestFromTracesFunc(nil)) require.NoError(t, err) require.NotNil(t, te) @@ -239,7 +241,7 @@ func TestTracesRequest_WithRecordMetrics_RequestSenderError(t *testing.T) { te, err := NewTracesRequest(context.Background(), exporter.Settings{ID: fakeTracesName, TelemetrySettings: tt.TelemetrySettings(), BuildInfo: component.NewDefaultBuildInfo()}, - (&internal.FakeRequestConverter{RequestError: want}).RequestFromTracesFunc) + internal.RequestFromTracesFunc(want)) require.NoError(t, err) require.NotNil(t, te) @@ -292,7 +294,7 @@ func TestTracesRequest_WithSpan(t *testing.T) { otel.SetTracerProvider(set.TracerProvider) defer otel.SetTracerProvider(nooptrace.NewTracerProvider()) - te, err := NewTracesRequest(context.Background(), set, (&internal.FakeRequestConverter{}).RequestFromTracesFunc) + te, err := NewTracesRequest(context.Background(), set, internal.RequestFromTracesFunc(nil)) require.NoError(t, err) require.NotNil(t, te) @@ -322,7 +324,7 @@ func TestTracesRequest_WithSpan_ExportError(t *testing.T) { defer otel.SetTracerProvider(nooptrace.NewTracerProvider()) want := errors.New("export_error") - te, err := NewTracesRequest(context.Background(), set, (&internal.FakeRequestConverter{RequestError: want}).RequestFromTracesFunc) + te, err := NewTracesRequest(context.Background(), set, internal.RequestFromTracesFunc(want)) require.NoError(t, err) require.NotNil(t, te) @@ -347,7 +349,7 @@ func TestTracesRequest_WithShutdown(t *testing.T) { shutdown := func(context.Context) error { shutdownCalled = true; return nil } te, err := NewTracesRequest(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{}).RequestFromTracesFunc, WithShutdown(shutdown)) + internal.RequestFromTracesFunc(nil), WithShutdown(shutdown)) assert.NotNil(t, te) assert.NoError(t, err) @@ -373,7 +375,7 @@ func TestTracesRequest_WithShutdown_ReturnError(t *testing.T) { shutdownErr := func(context.Context) error { return want } te, err := NewTracesRequest(context.Background(), exportertest.NewNopSettings(), - (&internal.FakeRequestConverter{}).RequestFromTracesFunc, WithShutdown(shutdownErr)) + internal.RequestFromTracesFunc(nil), WithShutdown(shutdownErr)) assert.NotNil(t, te) assert.NoError(t, err)