Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
moh-osman3 committed Jun 22, 2023
1 parent bbdd314 commit 56312cb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions collector/gen/exporter/fileexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func createTracesExporter(
if err != nil {
return nil, err
}
fe, err := exporters.GetOrAdd(cfg, func() (component.Component, error) {
fe, err := exporters.GetOrAdd(conf, func() (component.Component, error) {
return newFileExporter(conf, writer), nil
})
if err != nil {
Expand All @@ -84,7 +84,7 @@ func createMetricsExporter(
if err != nil {
return nil, err
}
fe, err := exporters.GetOrAdd(cfg, func() (component.Component, error) {
fe, err := exporters.GetOrAdd(conf, func() (component.Component, error) {
return newFileExporter(conf, writer), nil
})
if err != nil {
Expand All @@ -111,7 +111,7 @@ func createLogsExporter(
if err != nil {
return nil, err
}
fe, err := exporters.GetOrAdd(cfg, func() (component.Component, error) {
fe, err := exporters.GetOrAdd(conf, func() (component.Component, error) {
return newFileExporter(conf, writer), nil
})
if err != nil {
Expand Down Expand Up @@ -172,4 +172,4 @@ func buildFileWriter(cfg *Config, logger *zap.Logger) (WriteCloseFlusher, error)
// We maintain this map because the Factory is asked trace and metric receivers separately
// when it gets CreateTracesReceiver() and CreateMetricsReceiver() but they must not
// create separate objects, they must use one Receiver object per configuration.
var exporters = sharedcomponent.NewSharedComponents[component.Config, component.Component]()
var exporters = sharedcomponent.NewSharedComponents[*Config, component.Component]()
20 changes: 10 additions & 10 deletions collector/gen/exporter/fileexporter/file_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestFileTracesExporter(t *testing.T) {
}
require.NotNil(t, fe)

td := testdata.GenerateTracesTwoSpansSameResource()
td := testdata.GenerateTraces(2)
assert.NoError(t, fe.Start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, fe.consumeTraces(context.Background(), td))
assert.NoError(t, fe.consumeTraces(context.Background(), td))
Expand Down Expand Up @@ -176,7 +176,7 @@ func TestFileTracesExporterError(t *testing.T) {
}
require.NotNil(t, fe)

td := testdata.GenerateTracesTwoSpansSameResource()
td := testdata.GenerateTraces(2)
// Cannot call Start since we inject directly the WriterCloser.
assert.Error(t, fe.consumeTraces(context.Background(), td))
assert.NoError(t, fe.Shutdown(context.Background()))
Expand Down Expand Up @@ -267,7 +267,7 @@ func TestFileMetricsExporter(t *testing.T) {
}
require.NotNil(t, fe)

md := testdata.GenerateMetricsTwoMetrics()
md := testdata.GenerateMetrics(2)
assert.NoError(t, fe.Start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, fe.consumeMetrics(context.Background(), md))
assert.NoError(t, fe.consumeMetrics(context.Background(), md))
Expand Down Expand Up @@ -314,7 +314,7 @@ func TestFileMetricsExporterError(t *testing.T) {
}
require.NotNil(t, fe)

md := testdata.GenerateMetricsTwoMetrics()
md := testdata.GenerateMetrics(2)
// Cannot call Start since we inject directly the WriterCloser.
assert.Error(t, fe.consumeMetrics(context.Background(), md))
assert.NoError(t, fe.Shutdown(context.Background()))
Expand Down Expand Up @@ -405,7 +405,7 @@ func TestFileLogsExporter(t *testing.T) {
}
require.NotNil(t, fe)

ld := testdata.GenerateLogsTwoLogRecordsSameResource()
ld := testdata.GenerateLogs(2)
assert.NoError(t, fe.Start(context.Background(), componenttest.NewNopHost()))
assert.NoError(t, fe.consumeLogs(context.Background(), ld))
assert.NoError(t, fe.consumeLogs(context.Background(), ld))
Expand Down Expand Up @@ -452,7 +452,7 @@ func TestFileLogsExporterErrors(t *testing.T) {
}
require.NotNil(t, fe)

ld := testdata.GenerateLogsTwoLogRecordsSameResource()
ld := testdata.GenerateLogs(2)
// Cannot call Start since we inject directly the WriterCloser.
assert.Error(t, fe.consumeLogs(context.Background(), ld))
assert.NoError(t, fe.Shutdown(context.Background()))
Expand Down Expand Up @@ -488,7 +488,7 @@ func TestExportMessageAsBuffer(t *testing.T) {
}
require.NotNil(t, fe)

ld := testdata.GenerateLogsManyLogRecordsSameResource(15000)
ld := testdata.GenerateLogs(15000)
marshaler := &plog.ProtoMarshaler{}
buf, err := marshaler.MarshalLogs(ld)
assert.NoError(t, err)
Expand Down Expand Up @@ -569,9 +569,9 @@ func TestConcurrentlyCompress(t *testing.T) {
cmd []byte
cld []byte
)
td := testdata.GenerateTracesTwoSpansSameResource()
md := testdata.GenerateMetricsTwoMetrics()
ld := testdata.GenerateLogsTwoLogRecordsSameResource()
td := testdata.GenerateTraces(2)
md := testdata.GenerateMetrics(2)
ld := testdata.GenerateLogs(2)
go func() {
defer wg.Done()
buf, err := tracesMarshalers[formatTypeJSON].MarshalTraces(td)
Expand Down
2 changes: 1 addition & 1 deletion collector/gen/receiver/otlpreceiver/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ func TestGRPCInvalidTLSCredentials(t *testing.T) {

assert.EqualError(t,
r.Start(context.Background(), componenttest.NewNopHost()),
`failed to load TLS config: for auth via TLS, either both certificate and key must be supplied, or neither`)
`failed to load TLS config: failed to load TLS cert and key: for auth via TLS, provide both certificate and key, or neither`)
}

func TestGRPCMaxRecvSize(t *testing.T) {
Expand Down

0 comments on commit 56312cb

Please sign in to comment.