diff --git a/exporter/datasetexporter/README.md b/exporter/datasetexporter/README.md index 221bfd1f9dce..2aa362d9210e 100644 --- a/exporter/datasetexporter/README.md +++ b/exporter/datasetexporter/README.md @@ -29,7 +29,7 @@ If you do not want to specify `api_key` in the file, you can use the [builtin fu - `group_by` (default = []): The list of attributes based on which events should be grouped. - `retry_initial_interval` (default = 5s): Time to wait after the first failure before retrying. - `retry_max_interval` (default = 30s): Is the upper bound on backoff. - - `max_elapsed_time` (default = 300s): Is the maximum amount of time spent trying to send a buffer. + - `retry_max_elapsed_time` (default = 300s): Is the maximum amount of time spent trying to send a buffer. - `traces`: - `aggregate` (default = false): Count the number of spans and errors belonging to a trace. - `max_wait` (default = 5s): The maximum waiting for all spans from single trace to arrive; ignored if `aggregate` is false. @@ -67,4 +67,4 @@ service: processors: [batch] # add dataset among your exporters exporters: [dataset] -``` \ No newline at end of file +``` diff --git a/exporter/datasetexporter/config_test.go b/exporter/datasetexporter/config_test.go index d25b64977709..66c38e6d09d4 100644 --- a/exporter/datasetexporter/config_test.go +++ b/exporter/datasetexporter/config_test.go @@ -5,28 +5,15 @@ package datasetexporter import ( "fmt" - "os" "testing" "time" - "github.com/stretchr/testify/suite" + "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/confmap" "go.opentelemetry.io/collector/exporter/exporterhelper" ) -type SuiteConfig struct { - suite.Suite -} - -func TestSuiteConfig(t *testing.T) { - suite.Run(t, new(SuiteConfig)) -} - -func (s *SuiteConfig) SetupTest() { - os.Clearenv() -} - -func (s *SuiteConfig) TestConfigUnmarshalUnknownAttributes() { +func TestConfigUnmarshalUnknownAttributes(t *testing.T) { f := NewFactory() config := f.CreateDefaultConfig().(*Config) configMap := confmap.NewFromStringMap(map[string]interface{}{ @@ -39,10 +26,10 @@ func (s *SuiteConfig) TestConfigUnmarshalUnknownAttributes() { unmarshalErr := fmt.Errorf("1 error(s) decoding:\n\n* '' has invalid keys: unknown_attribute") expectedError := fmt.Errorf("cannot unmarshal config: %w", unmarshalErr) - s.Equal(expectedError.Error(), err.Error()) + assert.Equal(t, expectedError.Error(), err.Error()) } -func (s *SuiteConfig) TestConfigUseDefaults() { +func TestConfigUseDefaults(t *testing.T) { f := NewFactory() config := f.CreateDefaultConfig().(*Config) configMap := confmap.NewFromStringMap(map[string]interface{}{ @@ -50,15 +37,15 @@ func (s *SuiteConfig) TestConfigUseDefaults() { "api_key": "secret", }) err := config.Unmarshal(configMap) - s.Nil(err) + assert.Nil(t, err) - s.Equal("https://example.com", config.DatasetURL) - s.Equal("secret", string(config.APIKey)) - s.Equal(bufferMaxLifetime, config.MaxLifetime) - s.Equal(tracesMaxWait, config.TracesSettings.MaxWait) + assert.Equal(t, "https://example.com", config.DatasetURL) + assert.Equal(t, "secret", string(config.APIKey)) + assert.Equal(t, bufferMaxLifetime, config.MaxLifetime) + assert.Equal(t, tracesMaxWait, config.TracesSettings.MaxWait) } -func (s *SuiteConfig) TestConfigValidate() { +func TestConfigValidate(t *testing.T) { tests := []struct { name string config Config @@ -98,18 +85,18 @@ func (s *SuiteConfig) TestConfigValidate() { } for _, tt := range tests { - s.T().Run(tt.name, func(t *testing.T) { + t.Run(tt.name, func(t *testing.T) { err := tt.config.Validate() if err == nil { - s.Nil(tt.expected, tt.name) + assert.Nil(t, tt.expected, tt.name) } else { - s.Equal(tt.expected.Error(), err.Error(), tt.name) + assert.Equal(t, tt.expected.Error(), err.Error(), tt.name) } }) } } -func (s *SuiteConfig) TestConfigString() { +func TestConfigString(t *testing.T) { config := Config{ DatasetURL: "https://example.com", APIKey: "secret", @@ -126,7 +113,7 @@ func (s *SuiteConfig) TestConfigString() { TimeoutSettings: exporterhelper.NewDefaultTimeoutSettings(), } - s.Equal( + assert.Equal(t, "DatasetURL: https://example.com; BufferSettings: {MaxLifetime:123ns GroupBy:[field1 field2] RetryInitialInterval:0s RetryMaxInterval:0s RetryMaxElapsedTime:0s}; TracesSettings: {Aggregate:true MaxWait:45s}; RetrySettings: {Enabled:true InitialInterval:5s RandomizationFactor:0.5 Multiplier:1.5 MaxInterval:30s MaxElapsedTime:5m0s}; QueueSettings: {Enabled:true NumConsumers:10 QueueSize:1000 StorageID:}; TimeoutSettings: {Timeout:5s}", config.String(), ) diff --git a/exporter/datasetexporter/datasetexporter_test.go b/exporter/datasetexporter/datasetexporter_test.go index 5be570149b58..56d06e623df1 100644 --- a/exporter/datasetexporter/datasetexporter_test.go +++ b/exporter/datasetexporter/datasetexporter_test.go @@ -2,22 +2,3 @@ // SPDX-License-Identifier: Apache-2.0 package datasetexporter - -import ( - "os" - "testing" - - "github.com/stretchr/testify/suite" -) - -type SuiteDataSetExporter struct { - suite.Suite -} - -func (s *SuiteDataSetExporter) SuiteDataSetExporter() { - os.Clearenv() -} - -func TestSuiteDataSetExporter(t *testing.T) { - suite.Run(t, new(SuiteDataSetExporter)) -} diff --git a/exporter/datasetexporter/factory_test.go b/exporter/datasetexporter/factory_test.go index 217f39a9f80d..582c1130aa67 100644 --- a/exporter/datasetexporter/factory_test.go +++ b/exporter/datasetexporter/factory_test.go @@ -5,35 +5,23 @@ package datasetexporter import ( "fmt" - "os" "path/filepath" "testing" "time" - "github.com/stretchr/testify/suite" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/confmap/confmaptest" "go.opentelemetry.io/collector/exporter/exporterhelper" ) -type SuiteFactory struct { - suite.Suite -} - -func (s *SuiteFactory) SetupTest() { - os.Clearenv() -} - -func TestSuiteFactory(t *testing.T) { - suite.Run(t, new(SuiteFactory)) -} - -func (s *SuiteFactory) TestCreateDefaultConfig() { +func TestCreateDefaultConfig(t *testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() - s.Equal(&Config{ + assert.Equal(t, &Config{ BufferSettings: newDefaultBufferSettings(), TracesSettings: newDefaultTracesSettings(), RetrySettings: exporterhelper.NewDefaultRetrySettings(), @@ -41,12 +29,12 @@ func (s *SuiteFactory) TestCreateDefaultConfig() { TimeoutSettings: exporterhelper.NewDefaultTimeoutSettings(), }, cfg, "failed to create default config") - s.Nil(componenttest.CheckConfigStruct(cfg)) + assert.Nil(t, componenttest.CheckConfigStruct(cfg)) } -func (s *SuiteFactory) TestLoadConfig() { +func TestLoadConfig(t *testing.T) { cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) - s.Nil(err) + assert.Nil(t, err) tests := []struct { id component.ID @@ -118,15 +106,15 @@ func (s *SuiteFactory) TestLoadConfig() { } for _, tt := range tests { - s.T().Run(tt.id.Name(), func(*testing.T) { + t.Run(tt.id.Name(), func(*testing.T) { factory := NewFactory() cfg := factory.CreateDefaultConfig() sub, err := cm.Sub(tt.id.String()) - s.Require().Nil(err) - s.Require().Nil(component.UnmarshalConfig(sub, cfg)) - if s.Nil(component.ValidateConfig(cfg)) { - s.Equal(tt.expected, cfg) + require.Nil(t, err) + require.Nil(t, component.UnmarshalConfig(sub, cfg)) + if assert.Nil(t, component.ValidateConfig(cfg)) { + assert.Equal(t, tt.expected, cfg) } }) } diff --git a/exporter/datasetexporter/logs_exporter_stress_test.go b/exporter/datasetexporter/logs_exporter_stress_test.go index 830f212730de..0fb27a4afd26 100644 --- a/exporter/datasetexporter/logs_exporter_stress_test.go +++ b/exporter/datasetexporter/logs_exporter_stress_test.go @@ -13,14 +13,13 @@ import ( "math/rand" "net/http" "net/http/httptest" - "os" "strings" "sync" "sync/atomic" "testing" "time" - "github.com/stretchr/testify/suite" + "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/exporter/exporterhelper" "go.opentelemetry.io/collector/exporter/exportertest" @@ -28,19 +27,7 @@ import ( "go.opentelemetry.io/collector/pdata/plog" ) -type SuiteLogsE2EExporter struct { - suite.Suite -} - -func (s *SuiteLogsE2EExporter) SetupTest() { - os.Clearenv() -} - -func TestSuiteLogsE2EExporterIntegration(t *testing.T) { - suite.Run(t, new(SuiteLogsE2EExporter)) -} - -func (s *SuiteLogsE2EExporter) TestConsumeLogsManyLogsShouldSucceed() { +func TestConsumeLogsManyLogsShouldSucceed(t *testing.T) { const maxDelay = 200 * time.Millisecond createSettings := exportertest.NewNopCreateSettings() @@ -59,12 +46,12 @@ func (s *SuiteLogsE2EExporter) TestConsumeLogsManyLogsShouldSucceed() { attempt.Add(1) cer, err := extract(req) - s.NoError(err, "Error reading request: %v", err) + assert.NoError(t, err, "Error reading request: %v", err) for _, ev := range cer.Events { processedEvents.Add(1) key, found := ev.Attrs["body.str"] - s.True(found) + assert.True(t, found) mutex.Lock() sKey := key.(string) _, f := seenKeys[sKey] @@ -80,10 +67,10 @@ func (s *SuiteLogsE2EExporter) TestConsumeLogsManyLogsShouldSucceed() { "status": "success", "bytesCharged": 42, }) - s.NoError(err) + assert.NoError(t, err) l, err := w.Write(payload) - s.Greater(l, 1) - s.NoError(err) + assert.Greater(t, l, 1) + assert.NoError(t, err) })) defer server.Close() @@ -101,9 +88,9 @@ func (s *SuiteLogsE2EExporter) TestConsumeLogsManyLogsShouldSucceed() { logs, err := createLogsExporter(context.Background(), createSettings, config) waitingTime := time.Duration(0) - if s.NoError(err) { + if assert.NoError(t, err) { err = logs.Start(context.Background(), componenttest.NewNopHost()) - s.NoError(err) + assert.NoError(t, err) for bI := 0; bI < maxBatchCount; bI++ { batch := plog.NewLogs() @@ -119,19 +106,19 @@ func (s *SuiteLogsE2EExporter) TestConsumeLogsManyLogsShouldSucceed() { expectedKeys[key] = 1 } err = logs.ConsumeLogs(context.Background(), batch) - s.Nil(err) + assert.Nil(t, err) time.Sleep(time.Duration(float64(maxDelay.Nanoseconds()) * 0.7)) } - s.NotNil(logs) + assert.NotNil(t, logs) time.Sleep(time.Second) err = logs.Shutdown(context.Background()) - s.Nil(err) + assert.Nil(t, err) lastProcessed := uint64(0) sameNumber := 0 for { - s.T().Logf("Processed events: %d / %d", processedEvents.Load(), expectedLogs) + t.Logf("Processed events: %d / %d", processedEvents.Load(), expectedLogs) if lastProcessed == processedEvents.Load() { sameNumber++ } @@ -146,9 +133,9 @@ func (s *SuiteLogsE2EExporter) TestConsumeLogsManyLogsShouldSucceed() { time.Sleep(2 * time.Second) - s.True(wasSuccessful.Load()) + assert.True(t, wasSuccessful.Load()) - s.Equal(seenKeys, expectedKeys) - s.Equal(expectedLogs, processedEvents.Load(), "processed items") - s.Equal(expectedLogs, uint64(len(seenKeys)), "unique items") + assert.Equal(t, seenKeys, expectedKeys) + assert.Equal(t, expectedLogs, processedEvents.Load(), "processed items") + assert.Equal(t, expectedLogs, uint64(len(seenKeys)), "unique items") } diff --git a/exporter/datasetexporter/logs_exporter_test.go b/exporter/datasetexporter/logs_exporter_test.go index 3890df04be33..819c1ffca7ae 100644 --- a/exporter/datasetexporter/logs_exporter_test.go +++ b/exporter/datasetexporter/logs_exporter_test.go @@ -11,14 +11,13 @@ import ( "io" "net/http" "net/http/httptest" - "os" "sync/atomic" "testing" "time" "github.com/scalyr/dataset-go/pkg/api/add_events" "github.com/scalyr/dataset-go/pkg/api/request" - "github.com/stretchr/testify/suite" + "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/exporter/exporterhelper" "go.opentelemetry.io/collector/exporter/exportertest" @@ -28,50 +27,38 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" ) -type SuiteLogsExporter struct { - suite.Suite -} - -func (s *SuiteLogsExporter) SetupTest() { - os.Clearenv() -} - -func TestSuiteLogsExporter(t *testing.T) { - suite.Run(t, new(SuiteLogsExporter)) -} - -func (s *SuiteLogsExporter) TestCreateLogsExporter() { +func TestCreateLogsExporter(t *testing.T) { ctx := context.Background() createSettings := exportertest.NewNopCreateSettings() tests := createExporterTests() for _, tt := range tests { - s.T().Run(tt.name, func(*testing.T) { + t.Run(tt.name, func(*testing.T) { logs, err := createLogsExporter(ctx, createSettings, tt.config) if err == nil { - s.Nil(tt.expectedError, tt.name) - s.NotNil(logs, tt.name) + assert.Nil(t, tt.expectedError, tt.name) + assert.NotNil(t, logs, tt.name) } else { if tt.expectedError == nil { - s.Nil(err, tt.name) + assert.Nil(t, err, tt.name) } else { - s.Equal(tt.expectedError.Error(), err.Error(), tt.name) - s.Nil(logs, tt.name) + assert.Equal(t, tt.expectedError.Error(), err.Error(), tt.name) + assert.Nil(t, logs, tt.name) } } }) } } -func (s *SuiteLogsExporter) TestBuildBody() { +func TestBuildBody(t *testing.T) { slice := pcommon.NewValueSlice() err := slice.FromRaw([]any{1, 2, 3}) - s.NoError(err) + assert.NoError(t, err) bytes := pcommon.NewValueBytes() err = bytes.FromRaw([]byte{byte(65), byte(66), byte(67)}) - s.NoError(err) + assert.NoError(t, err) tests := []struct { body pcommon.Value key string @@ -123,20 +110,20 @@ func (s *SuiteLogsExporter) TestBuildBody() { } for _, tt := range tests { - s.T().Run(tt.key, func(*testing.T) { + t.Run(tt.key, func(*testing.T) { attrs := make(map[string]interface{}) msg := buildBody(attrs, tt.body) expectedAttrs := make(map[string]interface{}) expectedAttrs["body.type"] = tt.body.Type().String() expectedAttrs[tt.key] = tt.value - s.Equal(tt.message, msg, tt.key) - s.Equal(expectedAttrs, attrs, tt.key) + assert.Equal(t, tt.message, msg, tt.key) + assert.Equal(t, expectedAttrs, attrs, tt.key) }) } } -func (s *SuiteLogsExporter) TestBuildBodyMap() { +func TestBuildBodyMap(t *testing.T) { m := pcommon.NewValueMap() err := m.FromRaw(map[string]any{ "scalar": "scalar-value", @@ -146,7 +133,7 @@ func (s *SuiteLogsExporter) TestBuildBodyMap() { }, "array": []any{1, 2, 3}, }) - if s.NoError(err) { + if assert.NoError(t, err) { attrs := make(map[string]interface{}) msg := buildBody(attrs, m) expectedAttrs := make(map[string]interface{}) @@ -160,8 +147,8 @@ func (s *SuiteLogsExporter) TestBuildBodyMap() { expectedMsg := "{\"array\":[1,2,3],\"map\":{\"m1\":\"v1\",\"m2\":\"v2\"},\"scalar\":\"scalar-value\"}" - s.Equal(expectedMsg, msg) - s.Equal(expectedAttrs, attrs) + assert.Equal(t, expectedMsg, msg) + assert.Equal(t, expectedAttrs, attrs) } } @@ -224,7 +211,7 @@ var testLLog = &add_events.Log{ Attrs: map[string]interface{}{}, } -func (s *SuiteLogsExporter) TestBuildEventFromLog() { +func TestBuildEventFromLog(t *testing.T) { lr := testdata.GenerateLogsOneLogRecord() ld := lr.ResourceLogs().At(0).ScopeLogs().At(0).LogRecords().At(0) @@ -239,7 +226,7 @@ func (s *SuiteLogsExporter) TestBuildEventFromLog() { lr.ResourceLogs().At(0).ScopeLogs().At(0).Scope(), ) - s.Equal(expected, was) + assert.Equal(t, expected, was) } func extract(req *http.Request) (add_events.AddEventsRequest, error) { @@ -255,7 +242,7 @@ func extract(req *http.Request) (add_events.AddEventsRequest, error) { return *cer, err } -func (s *SuiteLogsExporter) TestConsumeLogsShouldSucceed() { +func TestConsumeLogsShouldSucceed(t *testing.T) { createSettings := exportertest.NewNopCreateSettings() attempt := atomic.Uint64{} @@ -267,17 +254,17 @@ func (s *SuiteLogsExporter) TestConsumeLogsShouldSucceed() { cer, err := extract(req) addRequest = cer - s.NoError(err, "Error reading request: %v", err) + assert.NoError(t, err, "Error reading request: %v", err) wasSuccessful.Store(true) payload, err := json.Marshal(map[string]interface{}{ "status": "success", "bytesCharged": 42, }) - s.NoError(err) + assert.NoError(t, err) l, err := w.Write(payload) - s.Greater(l, 1) - s.NoError(err) + assert.Greater(t, l, 1) + assert.NoError(t, err) })) defer server.Close() @@ -296,20 +283,20 @@ func (s *SuiteLogsExporter) TestConsumeLogsShouldSucceed() { lr := testdata.GenerateLogsOneLogRecord() logs, err := createLogsExporter(context.Background(), createSettings, config) - if s.NoError(err) { + if assert.NoError(t, err) { err = logs.Start(context.Background(), componenttest.NewNopHost()) - s.NoError(err) + assert.NoError(t, err) - s.NotNil(logs) + assert.NotNil(t, logs) err = logs.ConsumeLogs(context.Background(), lr) - s.Nil(err) + assert.Nil(t, err) time.Sleep(time.Second) err = logs.Shutdown(context.Background()) - s.Nil(err) + assert.Nil(t, err) } - s.True(wasSuccessful.Load()) - s.Equal( + assert.True(t, wasSuccessful.Load()) + assert.Equal(t, add_events.AddEventsRequest{ AuthParams: request.AuthParams{ Token: "key-lib", diff --git a/exporter/datasetexporter/traces_exporter_test.go b/exporter/datasetexporter/traces_exporter_test.go index 31d9ba347fbb..9d3666037ec5 100644 --- a/exporter/datasetexporter/traces_exporter_test.go +++ b/exporter/datasetexporter/traces_exporter_test.go @@ -6,14 +6,13 @@ package datasetexporter import ( "context" "fmt" - "os" "sort" "strings" "testing" "time" "github.com/scalyr/dataset-go/pkg/api/add_events" - "github.com/stretchr/testify/suite" + "github.com/stretchr/testify/assert" "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/ptrace" @@ -21,33 +20,21 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/testdata" ) -type SuiteTracesExporter struct { - suite.Suite -} - -func (s *SuiteTracesExporter) SetupTest() { - os.Clearenv() -} - -func TestSuiteTracesExporter(t *testing.T) { - suite.Run(t, new(SuiteTracesExporter)) -} - -func (s *SuiteTracesExporter) TestCreateTracesExporter() { +func TestCreateTracesExporter(t *testing.T) { ctx := context.Background() createSettings := exportertest.NewNopCreateSettings() tests := createExporterTests() for _, tt := range tests { - s.T().Run(tt.name, func(*testing.T) { + t.Run(tt.name, func(*testing.T) { logs, err := createTracesExporter(ctx, createSettings, tt.config) if err == nil { - s.Nil(tt.expectedError) - s.NotNil(logs) + assert.Nil(t, tt.expectedError) + assert.NotNil(t, logs) } else { - s.Equal(tt.expectedError.Error(), err.Error()) - s.Nil(logs) + assert.Equal(t, tt.expectedError.Error(), err.Error()) + assert.Nil(t, logs) } }) } @@ -148,7 +135,7 @@ var testTLog = &add_events.Log{ Attrs: map[string]interface{}{}, } -func (s *SuiteTracesExporter) TestBuildEventFromSpanOne() { +func TestBuildEventFromSpanOne(t *testing.T) { traces := testdata.GenerateTracesOneSpan() span := traces.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0) expected := &add_events.EventBundle{ @@ -165,10 +152,10 @@ func (s *SuiteTracesExporter) TestBuildEventFromSpanOne() { newSpanTracker(time.Hour), ) - s.Equal(expected, was) + assert.Equal(t, expected, was) } -func (s *SuiteTracesExporter) TestBuildEventsFromSpanAttributesCollision() { +func TestBuildEventsFromSpanAttributesCollision(t *testing.T) { td := ptrace.NewTraces() rs := td.ResourceSpans().AppendEmpty() rss := rs.ScopeSpans().AppendEmpty() @@ -215,10 +202,10 @@ func (s *SuiteTracesExporter) TestBuildEventsFromSpanAttributesCollision() { newSpanTracker(time.Hour), ) - s.Equal(expected, was) + assert.Equal(t, expected, was) } -func (s *SuiteTracesExporter) TestBuildEventsFromTracesFromTwoSpansSameResourceOneDifferent() { +func TestBuildEventsFromTracesFromTwoSpansSameResourceOneDifferent(t *testing.T) { traces := testdata.GenerateTracesTwoSpansSameResourceOneDifferent() was := buildEventsFromTraces(traces, newSpanTracker(time.Hour)) @@ -240,7 +227,7 @@ func (s *SuiteTracesExporter) TestBuildEventsFromTracesFromTwoSpansSameResourceO }, } - s.Equal(expected, was) + assert.Equal(t, expected, was) } var span0Id = [8]byte{1, 1, 1, 1, 1, 1, 1, 1} @@ -439,7 +426,7 @@ func generateSimpleEvent( } } -func (s *SuiteTracesExporter) TestBuildEventsFromTracesTreesAndOrphansWithTracker() { +func TestBuildEventsFromTracesTreesAndOrphansWithTracker(t *testing.T) { tracker := newSpanTracker(time.Second) traces := GenerateTracesTreesAndOrphans() was := buildEventsFromTraces(traces, tracker) @@ -533,7 +520,7 @@ func (s *SuiteTracesExporter) TestBuildEventsFromTracesTreesAndOrphansWithTracke expected[11].Event.Attrs["error_count"] = 0 expected[11].Event.Attrs["span_count"] = 1 - s.Equal(expected, was) + assert.Equal(t, expected, was) expectedKeys := []string{ newTraceAndSpan(trace2Id, span22PId).String(), @@ -551,14 +538,14 @@ func (s *SuiteTracesExporter) TestBuildEventsFromTracesTreesAndOrphansWithTracke return wasKeys[i] < wasKeys[j] }) - s.Equal(expectedKeys, wasKeys) - s.Equal(2, len(tracker.spans)) + assert.Equal(t, expectedKeys, wasKeys) + assert.Equal(t, 2, len(tracker.spans)) time.Sleep(time.Second) - s.Equal(2, tracker.purge()) - s.Equal(0, len(tracker.spans)) + assert.Equal(t, 2, tracker.purge()) + assert.Equal(t, 0, len(tracker.spans)) } -func (s *SuiteTracesExporter) TestBuildEventsFromTracesTreesAndOrphansWithoutTracker() { +func TestBuildEventsFromTracesTreesAndOrphansWithoutTracker(t *testing.T) { traces := GenerateTracesTreesAndOrphans() was := buildEventsFromTraces(traces, nil) @@ -629,10 +616,10 @@ func (s *SuiteTracesExporter) TestBuildEventsFromTracesTreesAndOrphansWithoutTra }, } - s.Equal(expected, was) + assert.Equal(t, expected, was) } -func (s *SuiteTracesExporter) TestUpdateResource() { +func TestUpdateResource(t *testing.T) { tests := []struct { name string resource map[string]any @@ -666,11 +653,11 @@ func (s *SuiteTracesExporter) TestUpdateResource() { } for _, tt := range tests { - s.T().Run(tt.name, func(*testing.T) { + t.Run(tt.name, func(*testing.T) { attrs := make(map[string]interface{}) updateResource(attrs, tt.resource) - s.Equal(tt.expected, attrs, tt.name) + assert.Equal(t, tt.expected, attrs, tt.name) }) } }