From 53ad0a40e7ae541081c2ddd8fdb0db6307a98fd1 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Thu, 29 Aug 2024 16:02:44 +0200 Subject: [PATCH] [chore]: enable bool-compare rule from testifylint (#34912) #### Description Testifylint is a linter that provides best practices with the use of testify. This PR enables [bool-compare](https://github.com/Antonboom/testifylint?tab=readme-ov-file#bool-compare) rule from [testifylint](https://github.com/Antonboom/testifylint) It's linter provided by golangci-lint. Here all available rules are activated except those who require to be fixed. This PR only fixes bool-compare so the quantity of changes stays reasonnable for reviewers. Signed-off-by: Matthieu MOREL --- .golangci.yml | 18 ++++++ connector/routingconnector/logs_test.go | 2 +- connector/routingconnector/metrics_test.go | 2 +- connector/routingconnector/traces_test.go | 2 +- .../internal/store/store_test.go | 12 ++-- .../spanmetricsconnector/connector_test.go | 2 +- .../alertmanager_exporter_test.go | 4 +- exporter/awss3exporter/s3_writer_test.go | 8 +-- .../internal/translator/segment_test.go | 8 +-- exporter/datasetexporter/config_test.go | 4 +- exporter/fileexporter/factory_test.go | 8 +-- .../logs_exporter_test.go | 2 +- .../internal/logs/sender_test.go | 4 +- .../internal/traces/sender_test.go | 4 +- exporter/lokiexporter/exporter_test.go | 2 +- .../prometheusexporter/accumulator_test.go | 2 +- exporter/syslogexporter/exporter_test.go | 2 +- extension/ackextension/inmemory_test.go | 60 +++++++++---------- extension/storage/filestorage/factory_test.go | 2 +- internal/aws/containerinsight/utils_test.go | 36 +++++------ .../aws/metrics/metric_calculator_test.go | 8 +-- internal/otelarrow/test/e2e_test.go | 2 +- .../entity_events_test.go | 2 +- pkg/translator/loki/logs_to_loki_test.go | 2 +- .../groupbyattrsprocessor/factory_test.go | 6 +- .../groupbytraceprocessor/processor_test.go | 2 +- processor/k8sattributesprocessor/e2e_test.go | 6 +- .../metrics_transform_processor_group_test.go | 2 +- .../metrics_transform_processor_test.go | 2 +- processor/redactionprocessor/factory_test.go | 2 +- processor/routingprocessor/logs_test.go | 2 +- processor/routingprocessor/metrics_test.go | 2 +- processor/routingprocessor/traces_test.go | 2 +- .../cadvisor/extractors/fs_extractor_test.go | 10 ++-- .../internal/ecsInfo/utils_test.go | 4 +- .../accumulator_test.go | 8 +-- .../awsecscontainermetrics/resource_test.go | 4 +- receiver/bigipreceiver/client_test.go | 6 +- receiver/datadogreceiver/receiver_test.go | 4 +- .../k8s_event_to_logdata_test.go | 6 +- receiver/k8seventsreceiver/receiver_test.go | 6 +- .../unstructured_to_logdata_test.go | 2 +- .../broker_scraper_test.go | 2 +- .../kafkareceiver/header_extraction_test.go | 2 +- receiver/prometheusreceiver/config_test.go | 4 +- .../targetallocator/manager_test.go | 4 +- .../snmpreceiver/otel_metric_helper_test.go | 12 ++-- .../unmarshaller_receive_test.go | 2 +- 48 files changed, 159 insertions(+), 141 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index fdd0fc238b15..144d9065ad2c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -132,6 +132,23 @@ linters-settings: predeclared: ignore: copy + testifylint: + disable: + - compares + - empty + - error-is-as + - error-nil + - expected-actual + - float-compare + - go-require + - len + - negative-positive + - nil-compare + - require-error + - suite-dont-use-pkg + - useless-assert + enable-all: true + linters: enable: - decorder @@ -152,6 +169,7 @@ linters: - revive - staticcheck - tenv + - testifylint - unconvert - unparam - unused diff --git a/connector/routingconnector/logs_test.go b/connector/routingconnector/logs_test.go index 6da7ef07c21e..a362028c2870 100644 --- a/connector/routingconnector/logs_test.go +++ b/connector/routingconnector/logs_test.go @@ -463,5 +463,5 @@ func TestLogsConnectorCapabilities(t *testing.T) { ) require.NoError(t, err) - assert.Equal(t, false, conn.Capabilities().MutatesData) + assert.False(t, conn.Capabilities().MutatesData) } diff --git a/connector/routingconnector/metrics_test.go b/connector/routingconnector/metrics_test.go index 366294289b2b..b3617060b4a1 100644 --- a/connector/routingconnector/metrics_test.go +++ b/connector/routingconnector/metrics_test.go @@ -493,5 +493,5 @@ func TestMetricsConnectorCapabilities(t *testing.T) { ) require.NoError(t, err) - assert.Equal(t, false, conn.Capabilities().MutatesData) + assert.False(t, conn.Capabilities().MutatesData) } diff --git a/connector/routingconnector/traces_test.go b/connector/routingconnector/traces_test.go index d7cd62b60f5d..7d7a1a62ab72 100644 --- a/connector/routingconnector/traces_test.go +++ b/connector/routingconnector/traces_test.go @@ -417,5 +417,5 @@ func TestTraceConnectorCapabilities(t *testing.T) { ) require.NoError(t, err) - assert.Equal(t, false, conn.Capabilities().MutatesData) + assert.False(t, conn.Capabilities().MutatesData) } diff --git a/connector/servicegraphconnector/internal/store/store_test.go b/connector/servicegraphconnector/internal/store/store_test.go index 189bdd11e7ed..c4cb02a398c7 100644 --- a/connector/servicegraphconnector/internal/store/store_test.go +++ b/connector/servicegraphconnector/internal/store/store_test.go @@ -30,7 +30,7 @@ func TestStoreUpsertEdge(t *testing.T) { e.ClientService = clientService }) require.NoError(t, err) - require.Equal(t, true, isNew) + require.True(t, isNew) assert.Equal(t, 1, s.Len()) // Nothing should be evicted as TTL is set to 1h @@ -44,7 +44,7 @@ func TestStoreUpsertEdge(t *testing.T) { e.ServerService = "server" }) require.NoError(t, err) - require.Equal(t, false, isNew) + require.False(t, isNew) // Edge is complete and should have been removed assert.Equal(t, 0, s.Len()) @@ -57,7 +57,7 @@ func TestStoreUpsertEdge(t *testing.T) { e.expiration = time.UnixMicro(0) }) require.NoError(t, err) - require.Equal(t, true, isNew) + require.True(t, isNew) assert.Equal(t, 1, s.Len()) assert.Equal(t, 1, onCompletedCount) assert.Equal(t, 0, onExpireCount) @@ -80,7 +80,7 @@ func TestStoreUpsertEdge_errTooManyItems(t *testing.T) { e.ClientService = clientService }) require.NoError(t, err) - require.Equal(t, true, isNew) + require.True(t, isNew) assert.Equal(t, 1, s.Len()) _, err = s.UpsertEdge(key2, func(e *Edge) { @@ -93,7 +93,7 @@ func TestStoreUpsertEdge_errTooManyItems(t *testing.T) { e.ClientService = clientService }) require.NoError(t, err) - require.Equal(t, false, isNew) + require.False(t, isNew) assert.Equal(t, 1, s.Len()) assert.Equal(t, 0, onCallbackCounter) @@ -120,7 +120,7 @@ func TestStoreExpire(t *testing.T) { for key := range keys { isNew, err := s.UpsertEdge(key, noopCallback) require.NoError(t, err) - require.Equal(t, true, isNew) + require.True(t, isNew) } s.Expire() diff --git a/connector/spanmetricsconnector/connector_test.go b/connector/spanmetricsconnector/connector_test.go index a58de25fbbc3..893a32c2ae31 100644 --- a/connector/spanmetricsconnector/connector_test.go +++ b/connector/spanmetricsconnector/connector_test.go @@ -692,7 +692,7 @@ func TestConnectorCapabilities(t *testing.T) { // Verify assert.NotNil(t, c) - assert.Equal(t, false, caps.MutatesData) + assert.False(t, caps.MutatesData) } type errConsumer struct { diff --git a/exporter/alertmanagerexporter/alertmanager_exporter_test.go b/exporter/alertmanagerexporter/alertmanager_exporter_test.go index 11117486f42c..b5f8f888ca10 100644 --- a/exporter/alertmanagerexporter/alertmanager_exporter_test.go +++ b/exporter/alertmanagerexporter/alertmanager_exporter_test.go @@ -138,11 +138,11 @@ func TestAlertManagerExporterEventNameAttributes(t *testing.T) { // test - count of attributes assert.Equal(t, 3, got[0].spanEvent.Attributes().Len()) attr, b := got[0].spanEvent.Attributes().Get("attr1") - assert.Equal(t, true, b) + assert.True(t, b) assert.Equal(t, "unittest-event", got[0].spanEvent.Name()) assert.Equal(t, "unittest-baz", attr.AsString()) attr, b = got[0].spanEvent.Attributes().Get("attr3") - assert.Equal(t, true, b) + assert.True(t, b) assert.Equal(t, 5.14, attr.Double()) } diff --git a/exporter/awss3exporter/s3_writer_test.go b/exporter/awss3exporter/s3_writer_test.go index 6df1998b07d5..350e3284f7d9 100644 --- a/exporter/awss3exporter/s3_writer_test.go +++ b/exporter/awss3exporter/s3_writer_test.go @@ -38,7 +38,7 @@ func TestS3Key(t *testing.T) { re := regexp.MustCompile(`keyprefix/year=2022/month=06/day=05/hour=00/minute=00/fileprefixlogs_([0-9]+).json`) s3Key := getS3Key(tm, "keyprefix", "minute", "fileprefix", "logs", "json", "") matched := re.MatchString(s3Key) - assert.Equal(t, true, matched) + assert.True(t, matched) } func TestS3KeyEmptyFileFormat(t *testing.T) { @@ -52,7 +52,7 @@ func TestS3KeyEmptyFileFormat(t *testing.T) { re := regexp.MustCompile(`keyprefix/year=2022/month=06/day=05/hour=00/minute=00/fileprefixlogs_([0-9]+)`) s3Key := getS3Key(tm, "keyprefix", "minute", "fileprefix", "logs", "", "") matched := re.MatchString(s3Key) - assert.Equal(t, true, matched) + assert.True(t, matched) } func TestS3KeyOfCompressedFile(t *testing.T) { @@ -66,7 +66,7 @@ func TestS3KeyOfCompressedFile(t *testing.T) { re := regexp.MustCompile(`keyprefix/year=2022/month=06/day=05/hour=00/minute=00/fileprefixlogs_([0-9]+).json.gz`) s3Key := getS3Key(tm, "keyprefix", "minute", "fileprefix", "logs", "json", "gzip") matched := re.MatchString(s3Key) - assert.Equal(t, true, matched) + assert.True(t, matched) } func TestS3KeyOfCompressedFileEmptyFileFormat(t *testing.T) { @@ -80,7 +80,7 @@ func TestS3KeyOfCompressedFileEmptyFileFormat(t *testing.T) { re := regexp.MustCompile(`keyprefix/year=2022/month=06/day=05/hour=00/minute=00/fileprefixlogs_([0-9]+).gz`) s3Key := getS3Key(tm, "keyprefix", "minute", "fileprefix", "logs", "", "gzip") matched := re.MatchString(s3Key) - assert.Equal(t, true, matched) + assert.True(t, matched) } func TestGetSessionConfigWithEndpoint(t *testing.T) { diff --git a/exporter/awsxrayexporter/internal/translator/segment_test.go b/exporter/awsxrayexporter/internal/translator/segment_test.go index 8b33edec28eb..1ef895c9c8b4 100644 --- a/exporter/awsxrayexporter/internal/translator/segment_test.go +++ b/exporter/awsxrayexporter/internal/translator/segment_test.go @@ -1252,7 +1252,7 @@ func validateLocalRootDependencySubsegment(t *testing.T, segment *awsxray.Segmen assert.Equal(t, "MySDK", *segment.AWS.XRay.SDK) assert.Equal(t, "1.20.0", *segment.AWS.XRay.SDKVersion) - assert.Equal(t, true, *segment.AWS.XRay.AutoInstrumentation) + assert.True(t, *segment.AWS.XRay.AutoInstrumentation) assert.Equal(t, "UpdateItem", *segment.AWS.Operation) assert.Equal(t, "AWSAccountAttribute", *segment.AWS.AccountID) @@ -1278,7 +1278,7 @@ func validateLocalRootServiceSegment(t *testing.T, segment *awsxray.Segment, spa assert.Equal(t, "service.name=myTest", segment.Metadata["default"]["otel.resource.attributes"]) assert.Equal(t, "MySDK", *segment.AWS.XRay.SDK) assert.Equal(t, "1.20.0", *segment.AWS.XRay.SDKVersion) - assert.Equal(t, true, *segment.AWS.XRay.AutoInstrumentation) + assert.True(t, *segment.AWS.XRay.AutoInstrumentation) assert.Nil(t, segment.AWS.Operation) assert.Nil(t, segment.AWS.AccountID) assert.Nil(t, segment.AWS.RemoteRegion) @@ -1406,7 +1406,7 @@ func TestNonLocalRootConsumerProcess(t *testing.T) { assert.Equal(t, "service.name=myTest", segments[0].Metadata["default"]["otel.resource.attributes"]) assert.Equal(t, "MySDK", *segments[0].AWS.XRay.SDK) assert.Equal(t, "1.20.0", *segments[0].AWS.XRay.SDKVersion) - assert.Equal(t, true, *segments[0].AWS.XRay.AutoInstrumentation) + assert.True(t, *segments[0].AWS.XRay.AutoInstrumentation) assert.Equal(t, "UpdateItem", *segments[0].AWS.Operation) assert.Nil(t, segments[0].Namespace) } @@ -1563,7 +1563,7 @@ func validateLocalRootWithoutDependency(t *testing.T, segment *awsxray.Segment, assert.Equal(t, "service.name=myTest", segment.Metadata["default"]["otel.resource.attributes"]) assert.Equal(t, "MySDK", *segment.AWS.XRay.SDK) assert.Equal(t, "1.20.0", *segment.AWS.XRay.SDKVersion) - assert.Equal(t, true, *segment.AWS.XRay.AutoInstrumentation) + assert.True(t, *segment.AWS.XRay.AutoInstrumentation) assert.Equal(t, "UpdateItem", *segment.AWS.Operation) assert.Equal(t, "AWSAccountAttribute", *segment.AWS.AccountID) diff --git a/exporter/datasetexporter/config_test.go b/exporter/datasetexporter/config_test.go index f036eef975af..545e596b7c75 100644 --- a/exporter/datasetexporter/config_test.go +++ b/exporter/datasetexporter/config_test.go @@ -157,7 +157,7 @@ func TestConfigUseProvidedExportResourceInfoValue(t *testing.T) { }) err := config.Unmarshal(configMap) assert.NoError(t, err) - assert.Equal(t, true, config.LogsSettings.ExportResourceInfo) + assert.True(t, config.LogsSettings.ExportResourceInfo) } func TestConfigUseProvidedExportScopeInfoValue(t *testing.T) { @@ -172,5 +172,5 @@ func TestConfigUseProvidedExportScopeInfoValue(t *testing.T) { }) err := config.Unmarshal(configMap) assert.NoError(t, err) - assert.Equal(t, false, config.LogsSettings.ExportScopeInfo) + assert.False(t, config.LogsSettings.ExportScopeInfo) } diff --git a/exporter/fileexporter/factory_test.go b/exporter/fileexporter/factory_test.go index b56d48de4a6c..1f8647537750 100644 --- a/exporter/fileexporter/factory_test.go +++ b/exporter/fileexporter/factory_test.go @@ -124,7 +124,7 @@ func TestNewFileWriter(t *testing.T) { validate: func(t *testing.T, writer *fileWriter) { assert.Equal(t, 5*time.Second, writer.flushInterval) _, ok := writer.file.(*bufferedWriteCloser) - assert.Equal(t, true, ok) + assert.True(t, ok) }, }, { @@ -139,7 +139,7 @@ func TestNewFileWriter(t *testing.T) { }, validate: func(t *testing.T, writer *fileWriter) { logger, ok := writer.file.(*lumberjack.Logger) - assert.Equal(t, true, ok) + assert.True(t, ok) assert.Equal(t, defaultMaxBackups, logger.MaxBackups) }, }, @@ -158,11 +158,11 @@ func TestNewFileWriter(t *testing.T) { }, validate: func(t *testing.T, writer *fileWriter) { logger, ok := writer.file.(*lumberjack.Logger) - assert.Equal(t, true, ok) + assert.True(t, ok) assert.Equal(t, 3, logger.MaxBackups) assert.Equal(t, 30, logger.MaxSize) assert.Equal(t, 100, logger.MaxAge) - assert.Equal(t, true, logger.LocalTime) + assert.True(t, logger.LocalTime) }, }, } diff --git a/exporter/honeycombmarkerexporter/logs_exporter_test.go b/exporter/honeycombmarkerexporter/logs_exporter_test.go index 7dfa7d3175a6..22f48e8e8c68 100644 --- a/exporter/honeycombmarkerexporter/logs_exporter_test.go +++ b/exporter/honeycombmarkerexporter/logs_exporter_test.go @@ -138,7 +138,7 @@ func TestExportMarkers(t *testing.T) { userAgent := req.Header.Get(userAgentHeaderKey) assert.NotEmpty(t, userAgent) - assert.Equal(t, strings.Contains(userAgent, "OpenTelemetry Collector"), true) + assert.True(t, strings.Contains(userAgent, "OpenTelemetry Collector")) rw.WriteHeader(http.StatusAccepted) })) diff --git a/exporter/logicmonitorexporter/internal/logs/sender_test.go b/exporter/logicmonitorexporter/internal/logs/sender_test.go index 03624995987a..d53b05fc90e1 100644 --- a/exporter/logicmonitorexporter/internal/logs/sender_test.go +++ b/exporter/logicmonitorexporter/internal/logs/sender_test.go @@ -64,7 +64,7 @@ func TestSendLogs(t *testing.T) { err = sender.SendLogs(ctx, []model.LogInput{logInput}) cancel() assert.Error(t, err) - assert.Equal(t, true, consumererror.IsPermanent(err)) + assert.True(t, consumererror.IsPermanent(err)) }) t.Run("should not return permanent failure error", func(t *testing.T) { @@ -87,7 +87,7 @@ func TestSendLogs(t *testing.T) { err = sender.SendLogs(ctx, []model.LogInput{logInput}) cancel() assert.Error(t, err) - assert.Equal(t, false, consumererror.IsPermanent(err)) + assert.False(t, consumererror.IsPermanent(err)) }) } diff --git a/exporter/logicmonitorexporter/internal/traces/sender_test.go b/exporter/logicmonitorexporter/internal/traces/sender_test.go index c9b07aafdf5f..ed1feacefdf4 100644 --- a/exporter/logicmonitorexporter/internal/traces/sender_test.go +++ b/exporter/logicmonitorexporter/internal/traces/sender_test.go @@ -64,7 +64,7 @@ func TestSendTraces(t *testing.T) { err = sender.SendTraces(ctx, testdata.GenerateTraces(1)) cancel() assert.Error(t, err) - assert.Equal(t, true, consumererror.IsPermanent(err)) + assert.True(t, consumererror.IsPermanent(err)) }) t.Run("should not return permanent failure error", func(t *testing.T) { @@ -86,6 +86,6 @@ func TestSendTraces(t *testing.T) { err = sender.SendTraces(ctx, testdata.GenerateTraces(1)) cancel() assert.Error(t, err) - assert.Equal(t, false, consumererror.IsPermanent(err)) + assert.False(t, consumererror.IsPermanent(err)) }) } diff --git a/exporter/lokiexporter/exporter_test.go b/exporter/lokiexporter/exporter_test.go index c0108aa49ce0..a7c1a5cb7fe0 100644 --- a/exporter/lokiexporter/exporter_test.go +++ b/exporter/lokiexporter/exporter_test.go @@ -276,7 +276,7 @@ func TestLogsToLokiRequestWithGroupingByTenant(t *testing.T) { assert.Equal(t, len(actualPushRequestPerTenant), len(tC.expected)) for tenant, request := range actualPushRequestPerTenant { pr, ok := tC.expected[tenant] - assert.Equal(t, ok, true) + assert.True(t, ok) expectedLabel := pr.label expectedLine := pr.line diff --git a/exporter/prometheusexporter/accumulator_test.go b/exporter/prometheusexporter/accumulator_test.go index 43b78ced5f01..49b39c4412bb 100644 --- a/exporter/prometheusexporter/accumulator_test.go +++ b/exporter/prometheusexporter/accumulator_test.go @@ -373,7 +373,7 @@ func TestAccumulateDeltaToCumulative(t *testing.T) { require.Equal(t, mValue, vValue) require.Equal(t, dataPointValue1+dataPointValue2, vValue) require.Equal(t, pmetric.AggregationTemporalityCumulative, vTemporality) - require.Equal(t, true, vIsMonotonic) + require.True(t, vIsMonotonic) require.Equal(t, ts3.Unix(), vTS.Unix()) }) diff --git a/exporter/syslogexporter/exporter_test.go b/exporter/syslogexporter/exporter_test.go index f2720ed4ac8a..212ea99d687c 100644 --- a/exporter/syslogexporter/exporter_test.go +++ b/exporter/syslogexporter/exporter_test.go @@ -168,7 +168,7 @@ func TestSyslogExportFail(t *testing.T) { consumerErr := test.exp.pushLogsData(context.Background(), logs) var consumerErrorLogs consumererror.Logs ok := errors.As(consumerErr, &consumerErrorLogs) - assert.Equal(t, ok, true) + assert.True(t, ok) consumerLogs := consumererror.Logs.Data(consumerErrorLogs) rls := consumerLogs.ResourceLogs() require.Equal(t, 1, rls.Len()) diff --git a/extension/ackextension/inmemory_test.go b/extension/ackextension/inmemory_test.go index 8e893866a5f7..5d9f4333db74 100644 --- a/extension/ackextension/inmemory_test.go +++ b/extension/ackextension/inmemory_test.go @@ -105,9 +105,9 @@ func TestExtensionAck_ProcessEvents_EventsUnAcked(t *testing.T) { for i := 0; i < 100; i++ { result := ext.QueryAcks(fmt.Sprintf("part-%d", i), []uint64{0, 1, 2}) require.Equal(t, len(result), 3) - require.Equal(t, result[0], false) - require.Equal(t, result[1], false) - require.Equal(t, result[2], false) + require.False(t, result[0]) + require.False(t, result[1]) + require.False(t, result[2]) } } @@ -141,15 +141,15 @@ func TestExtensionAck_ProcessEvents_EventsAcked(t *testing.T) { if i%2 == 0 { result := ext.QueryAcks(fmt.Sprintf("part-%d", i), []uint64{1, 2, 3}) require.Equal(t, len(result), 3) - require.Equal(t, result[1], false) - require.Equal(t, result[2], true) - require.Equal(t, result[3], false) + require.False(t, result[1]) + require.True(t, result[2]) + require.False(t, result[3]) } else { result := ext.QueryAcks(fmt.Sprintf("part-%d", i), []uint64{1, 2, 3}) require.Equal(t, len(result), 3) - require.Equal(t, result[1], true) - require.Equal(t, result[2], false) - require.Equal(t, result[3], true) + require.True(t, result[1]) + require.False(t, result[2]) + require.True(t, result[3]) } } } @@ -184,15 +184,15 @@ func TestExtensionAck_QueryAcks_Unidempotent(t *testing.T) { if i%2 == 0 { result := ext.QueryAcks(fmt.Sprintf("part-%d", i), []uint64{1, 2, 3}) require.Equal(t, len(result), 3) - require.Equal(t, result[1], false) - require.Equal(t, result[2], true) - require.Equal(t, result[3], false) + require.False(t, result[1]) + require.True(t, result[2]) + require.False(t, result[3]) } else { result := ext.QueryAcks(fmt.Sprintf("part-%d", i), []uint64{1, 2, 3}) require.Equal(t, len(result), 3) - require.Equal(t, result[1], true) - require.Equal(t, result[2], false) - require.Equal(t, result[3], true) + require.True(t, result[1]) + require.False(t, result[2]) + require.True(t, result[3]) } } @@ -200,9 +200,9 @@ func TestExtensionAck_QueryAcks_Unidempotent(t *testing.T) { for i := 0; i < 100; i++ { result := ext.QueryAcks(fmt.Sprintf("part-%d", i), []uint64{1, 2, 3}) require.Equal(t, len(result), 3) - require.Equal(t, result[1], false) - require.Equal(t, result[2], false) - require.Equal(t, result[3], false) + require.False(t, result[1]) + require.False(t, result[2]) + require.False(t, result[3]) } } @@ -234,9 +234,9 @@ func TestExtensionAckAsync(t *testing.T) { for i := 0; i < partitionCount; i++ { result := ext.QueryAcks(fmt.Sprintf("part-%d", i), []uint64{1, 2, 3}) require.Equal(t, len(result), 3) - require.Equal(t, result[1], false) - require.Equal(t, result[2], false) - require.Equal(t, result[3], false) + require.False(t, result[1]) + require.False(t, result[2]) + require.False(t, result[3]) } wg.Add(partitionCount) @@ -260,15 +260,15 @@ func TestExtensionAckAsync(t *testing.T) { if i%2 == 0 { result := ext.QueryAcks(fmt.Sprintf("part-%d", i), []uint64{1, 2, 3}) require.Equal(t, len(result), 3) - require.Equal(t, result[1], false) - require.Equal(t, result[2], true) - require.Equal(t, result[3], false) + require.False(t, result[1]) + require.True(t, result[2]) + require.False(t, result[3]) } else { result := ext.QueryAcks(fmt.Sprintf("part-%d", i), []uint64{1, 2, 3}) require.Equal(t, len(result), 3) - require.Equal(t, result[1], true) - require.Equal(t, result[2], false) - require.Equal(t, result[3], true) + require.True(t, result[1]) + require.False(t, result[2]) + require.True(t, result[3]) } } wg.Add(100) @@ -286,8 +286,8 @@ func TestExtensionAckAsync(t *testing.T) { for i := 0; i < partitionCount; i++ { result := <-resultChan require.Equal(t, len(result), 3) - require.Equal(t, result[1], false) - require.Equal(t, result[2], false) - require.Equal(t, result[3], false) + require.False(t, result[1]) + require.False(t, result[2]) + require.False(t, result[3]) } } diff --git a/extension/storage/filestorage/factory_test.go b/extension/storage/filestorage/factory_test.go index 448b7fe51047..875a18fec092 100644 --- a/extension/storage/filestorage/factory_test.go +++ b/extension/storage/filestorage/factory_test.go @@ -29,7 +29,7 @@ func TestFactory(t *testing.T) { require.Equal(t, expected, cfg.Directory) } require.Equal(t, time.Second, cfg.Timeout) - require.Equal(t, false, cfg.FSync) + require.False(t, cfg.FSync) tests := []struct { name string diff --git a/internal/aws/containerinsight/utils_test.go b/internal/aws/containerinsight/utils_test.go index 457cb7350b5c..87458895ac70 100644 --- a/internal/aws/containerinsight/utils_test.go +++ b/internal/aws/containerinsight/utils_test.go @@ -69,32 +69,32 @@ func TestMetricName(t *testing.T) { } func TestIsNode(t *testing.T) { - assert.Equal(t, true, IsNode(TypeNode)) - assert.Equal(t, true, IsNode(TypeNodeNet)) - assert.Equal(t, true, IsNode(TypeNodeFS)) - assert.Equal(t, true, IsNode(TypeNodeDiskIO)) - assert.Equal(t, false, IsNode(TypePod)) + assert.True(t, IsNode(TypeNode)) + assert.True(t, IsNode(TypeNodeNet)) + assert.True(t, IsNode(TypeNodeFS)) + assert.True(t, IsNode(TypeNodeDiskIO)) + assert.False(t, IsNode(TypePod)) } func TestIsInstance(t *testing.T) { - assert.Equal(t, true, IsInstance(TypeInstance)) - assert.Equal(t, true, IsInstance(TypeInstanceNet)) - assert.Equal(t, true, IsInstance(TypeInstanceFS)) - assert.Equal(t, true, IsInstance(TypeInstanceDiskIO)) - assert.Equal(t, false, IsInstance(TypePod)) + assert.True(t, IsInstance(TypeInstance)) + assert.True(t, IsInstance(TypeInstanceNet)) + assert.True(t, IsInstance(TypeInstanceFS)) + assert.True(t, IsInstance(TypeInstanceDiskIO)) + assert.False(t, IsInstance(TypePod)) } func TestIsContainer(t *testing.T) { - assert.Equal(t, true, IsContainer(TypeContainer)) - assert.Equal(t, true, IsContainer(TypeContainerDiskIO)) - assert.Equal(t, true, IsContainer(TypeContainerFS)) - assert.Equal(t, false, IsContainer(TypePod)) + assert.True(t, IsContainer(TypeContainer)) + assert.True(t, IsContainer(TypeContainerDiskIO)) + assert.True(t, IsContainer(TypeContainerFS)) + assert.False(t, IsContainer(TypePod)) } func TestIsPod(t *testing.T) { - assert.Equal(t, true, IsPod(TypePod)) - assert.Equal(t, true, IsPod(TypePodNet)) - assert.Equal(t, false, IsPod(TypeInstance)) + assert.True(t, IsPod(TypePod)) + assert.True(t, IsPod(TypePodNet)) + assert.False(t, IsPod(TypeInstance)) } func convertToInt64(value any) int64 { @@ -145,7 +145,7 @@ func checkMetricsAreExpected(t *testing.T, md pmetric.Metrics, fields map[string for key, val := range tags { log.Printf("key=%v value=%v", key, val) attr, ok := attributes.Get(key) - assert.Equal(t, true, ok) + assert.True(t, ok) if key == Timestamp { timeUnixNano, _ = strconv.ParseUint(val, 10, 64) val = strconv.FormatUint(timeUnixNano/uint64(time.Millisecond), 10) diff --git a/internal/aws/metrics/metric_calculator_test.go b/internal/aws/metrics/metric_calculator_test.go index 27a32d0f62ae..04e41829489c 100644 --- a/internal/aws/metrics/metric_calculator_test.go +++ b/internal/aws/metrics/metric_calculator_test.go @@ -106,13 +106,13 @@ func TestMapWithExpiryAdd(t *testing.T) { store.Set(Key{MetricMetadata: "key1"}, MetricValue{RawValue: value1}) val, ok := store.Get(Key{MetricMetadata: "key1"}) store.Unlock() - assert.Equal(t, true, ok) + assert.True(t, ok) assert.Equal(t, value1, val.RawValue) store.Lock() defer store.Unlock() val, ok = store.Get(Key{MetricMetadata: "key2"}) - assert.Equal(t, false, ok) + assert.False(t, ok) assert.True(t, val == nil) require.NoError(t, store.Shutdown()) } @@ -134,7 +134,7 @@ func TestMapWithExpiryCleanup(t *testing.T) { val, ok := store.Get(Key{MetricMetadata: "key1"}) - assert.Equal(t, true, ok) + assert.True(t, ok) assert.Equal(t, value1, val.RawValue.(float64)) assert.Equal(t, 1, store.Size()) store.Unlock() @@ -143,7 +143,7 @@ func TestMapWithExpiryCleanup(t *testing.T) { store.CleanUp(time.Now()) store.Lock() val, ok = store.Get(Key{MetricMetadata: "key1"}) - assert.Equal(t, false, ok) + assert.False(t, ok) assert.True(t, val == nil) assert.Equal(t, 0, store.Size()) store.Unlock() diff --git a/internal/otelarrow/test/e2e_test.go b/internal/otelarrow/test/e2e_test.go index 080b44f58e86..85783b00361a 100644 --- a/internal/otelarrow/test/e2e_test.go +++ b/internal/otelarrow/test/e2e_test.go @@ -377,7 +377,7 @@ func consumerFailure(t *testing.T, err error) { require.Error(t, err) // there should be no permanent errors anywhere in this test. - require.True(t, !consumererror.IsPermanent(err), + require.False(t, consumererror.IsPermanent(err), "should not be permanent: %v", err) stat, ok := status.FromError(err) diff --git a/pkg/experimentalmetricmetadata/entity_events_test.go b/pkg/experimentalmetricmetadata/entity_events_test.go index e6e5e1bf66e5..13c13cec2f35 100644 --- a/pkg/experimentalmetricmetadata/entity_events_test.go +++ b/pkg/experimentalmetricmetadata/entity_events_test.go @@ -91,7 +91,7 @@ func Test_EntityEventsSlice_ConvertAndMoveToLogs(t *testing.T) { // Check the Scope v, ok := scopeLogs.Scope().Attributes().Get(semconvOtelEntityEventAsScope) assert.True(t, ok) - assert.Equal(t, true, v.Bool()) + assert.True(t, v.Bool()) records := scopeLogs.LogRecords() assert.Equal(t, 2, records.Len()) diff --git a/pkg/translator/loki/logs_to_loki_test.go b/pkg/translator/loki/logs_to_loki_test.go index af5c09ff9f4e..d14486089658 100644 --- a/pkg/translator/loki/logs_to_loki_test.go +++ b/pkg/translator/loki/logs_to_loki_test.go @@ -218,7 +218,7 @@ func TestLogsToLokiRequestWithGroupingByTenant(t *testing.T) { for tenant, request := range requests { want, ok := tt.expected[tenant] - assert.Equal(t, ok, true) + assert.True(t, ok) streams := request.Streams for s := 0; s < len(streams); s++ { diff --git a/processor/groupbyattrsprocessor/factory_test.go b/processor/groupbyattrsprocessor/factory_test.go index 1b4cd30b1319..885049330a87 100644 --- a/processor/groupbyattrsprocessor/factory_test.go +++ b/processor/groupbyattrsprocessor/factory_test.go @@ -26,17 +26,17 @@ func TestCreateTestProcessor(t *testing.T) { tp, err := createTracesProcessor(context.Background(), processortest.NewNopSettings(), cfg, consumertest.NewNop()) assert.NoError(t, err) assert.NotNil(t, tp) - assert.Equal(t, true, tp.Capabilities().MutatesData) + assert.True(t, tp.Capabilities().MutatesData) lp, err := createLogsProcessor(context.Background(), processortest.NewNopSettings(), cfg, consumertest.NewNop()) assert.NoError(t, err) assert.NotNil(t, lp) - assert.Equal(t, true, lp.Capabilities().MutatesData) + assert.True(t, lp.Capabilities().MutatesData) mp, err := createMetricsProcessor(context.Background(), processortest.NewNopSettings(), cfg, consumertest.NewNop()) assert.NoError(t, err) assert.NotNil(t, mp) - assert.Equal(t, true, mp.Capabilities().MutatesData) + assert.True(t, mp.Capabilities().MutatesData) } func TestNoKeys(t *testing.T) { diff --git a/processor/groupbytraceprocessor/processor_test.go b/processor/groupbytraceprocessor/processor_test.go index ddc7675a055f..4e65362e5599 100644 --- a/processor/groupbytraceprocessor/processor_test.go +++ b/processor/groupbytraceprocessor/processor_test.go @@ -152,7 +152,7 @@ func TestProcessorCapabilities(t *testing.T) { // verify assert.NotNil(t, p) - assert.Equal(t, true, caps.MutatesData) + assert.True(t, caps.MutatesData) } func TestProcessBatchDoesntFail(t *testing.T) { diff --git a/processor/k8sattributesprocessor/e2e_test.go b/processor/k8sattributesprocessor/e2e_test.go index ef0b553ca320..780dd6fe9793 100644 --- a/processor/k8sattributesprocessor/e2e_test.go +++ b/processor/k8sattributesprocessor/e2e_test.go @@ -896,7 +896,7 @@ func scanTracesForAttributes(t *testing.T, ts *consumertest.TracesSink, expected for i := 0; i < traces.ResourceSpans().Len(); i++ { resource := traces.ResourceSpans().At(i).Resource() service, exist := resource.Attributes().Get("service.name") - assert.Equal(t, true, exist, "span do not has 'service.name' attribute in resource") + assert.True(t, exist, "span do not has 'service.name' attribute in resource") if service.AsString() != expectedService { continue } @@ -917,7 +917,7 @@ func scanMetricsForAttributes(t *testing.T, ms *consumertest.MetricsSink, expect for i := 0; i < metrics.ResourceMetrics().Len(); i++ { resource := metrics.ResourceMetrics().At(i).Resource() service, exist := resource.Attributes().Get("service.name") - assert.Equal(t, true, exist, "metric do not has 'service.name' attribute in resource") + assert.True(t, exist, "metric do not has 'service.name' attribute in resource") if service.AsString() != expectedService { continue } @@ -938,7 +938,7 @@ func scanLogsForAttributes(t *testing.T, ls *consumertest.LogsSink, expectedServ for i := 0; i < logs.ResourceLogs().Len(); i++ { resource := logs.ResourceLogs().At(i).Resource() service, exist := resource.Attributes().Get("service.name") - assert.Equal(t, true, exist, "log do not has 'service.name' attribute in resource") + assert.True(t, exist, "log do not has 'service.name' attribute in resource") if service.AsString() != expectedService { continue } diff --git a/processor/metricstransformprocessor/metrics_transform_processor_group_test.go b/processor/metricstransformprocessor/metrics_transform_processor_group_test.go index 1f38ab8b3a49..85bf8b9e7694 100644 --- a/processor/metricstransformprocessor/metrics_transform_processor_group_test.go +++ b/processor/metricstransformprocessor/metrics_transform_processor_group_test.go @@ -75,7 +75,7 @@ func TestMetricsGrouping(t *testing.T) { require.NoError(t, err) caps := mtp.Capabilities() - assert.Equal(t, true, caps.MutatesData) + assert.True(t, caps.MutatesData) input, err := golden.ReadMetrics(filepath.Join("testdata", "operation_group", test.name+"_in.yaml")) require.NoError(t, err) diff --git a/processor/metricstransformprocessor/metrics_transform_processor_test.go b/processor/metricstransformprocessor/metrics_transform_processor_test.go index e746db070630..22e5b851a304 100644 --- a/processor/metricstransformprocessor/metrics_transform_processor_test.go +++ b/processor/metricstransformprocessor/metrics_transform_processor_test.go @@ -37,7 +37,7 @@ func TestMetricsTransformProcessor(t *testing.T) { require.NoError(t, err) caps := mtp.Capabilities() - assert.Equal(t, true, caps.MutatesData) + assert.True(t, caps.MutatesData) // process inMetrics := pmetric.NewMetrics() diff --git a/processor/redactionprocessor/factory_test.go b/processor/redactionprocessor/factory_test.go index e0a667fc0b55..7afe5741c794 100644 --- a/processor/redactionprocessor/factory_test.go +++ b/processor/redactionprocessor/factory_test.go @@ -24,5 +24,5 @@ func TestCreateTestProcessor(t *testing.T) { tp, err := createTracesProcessor(context.Background(), processortest.NewNopSettings(), cfg, consumertest.NewNop()) assert.NoError(t, err) assert.NotNil(t, tp) - assert.Equal(t, true, tp.Capabilities().MutatesData) + assert.True(t, tp.Capabilities().MutatesData) } diff --git a/processor/routingprocessor/logs_test.go b/processor/routingprocessor/logs_test.go index e0f94ef90ef7..2639517ceecb 100644 --- a/processor/routingprocessor/logs_test.go +++ b/processor/routingprocessor/logs_test.go @@ -32,7 +32,7 @@ func TestLogProcessorCapabilities(t *testing.T) { require.NotNil(t, p) // verify - assert.Equal(t, false, p.Capabilities().MutatesData) + assert.False(t, p.Capabilities().MutatesData) } func TestLogs_RoutingWorks_Context(t *testing.T) { diff --git a/processor/routingprocessor/metrics_test.go b/processor/routingprocessor/metrics_test.go index d5404eaa0aaf..2d6937b890d2 100644 --- a/processor/routingprocessor/metrics_test.go +++ b/processor/routingprocessor/metrics_test.go @@ -33,7 +33,7 @@ func TestMetricProcessorCapabilities(t *testing.T) { require.NotNil(t, p) // verify - assert.Equal(t, false, p.Capabilities().MutatesData) + assert.False(t, p.Capabilities().MutatesData) } func TestMetrics_AreCorrectlySplitPerResourceAttributeRouting(t *testing.T) { diff --git a/processor/routingprocessor/traces_test.go b/processor/routingprocessor/traces_test.go index 0be65e294c18..d7ae15ceb4ec 100644 --- a/processor/routingprocessor/traces_test.go +++ b/processor/routingprocessor/traces_test.go @@ -515,7 +515,7 @@ func TestTraceProcessorCapabilities(t *testing.T) { require.NotNil(t, p) // verify - assert.Equal(t, false, p.Capabilities().MutatesData) + assert.False(t, p.Capabilities().MutatesData) } type mockTracesExporter struct { diff --git a/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/fs_extractor_test.go b/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/fs_extractor_test.go index 41dd6a57ef62..5e942cf80339 100644 --- a/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/fs_extractor_test.go +++ b/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/fs_extractor_test.go @@ -107,11 +107,11 @@ func TestFSStats(t *testing.T) { func TestAllowList(t *testing.T) { extractor := NewFileSystemMetricExtractor(nil) - assert.Equal(t, true, extractor.allowListRegexP.MatchString("/dev/shm")) - assert.Equal(t, true, extractor.allowListRegexP.MatchString("tmpfs")) - assert.Equal(t, true, extractor.allowListRegexP.MatchString("overlay")) - assert.Equal(t, false, extractor.allowListRegexP.MatchString("overlaytest")) - assert.Equal(t, false, extractor.allowListRegexP.MatchString("/dev")) + assert.True(t, extractor.allowListRegexP.MatchString("/dev/shm")) + assert.True(t, extractor.allowListRegexP.MatchString("tmpfs")) + assert.True(t, extractor.allowListRegexP.MatchString("overlay")) + assert.False(t, extractor.allowListRegexP.MatchString("overlaytest")) + assert.False(t, extractor.allowListRegexP.MatchString("/dev")) } func TestFSStatsWithAllowList(t *testing.T) { diff --git a/receiver/awscontainerinsightreceiver/internal/ecsInfo/utils_test.go b/receiver/awscontainerinsightreceiver/internal/ecsInfo/utils_test.go index 7060b60ad52b..5da8c810b219 100644 --- a/receiver/awscontainerinsightreceiver/internal/ecsInfo/utils_test.go +++ b/receiver/awscontainerinsightreceiver/internal/ecsInfo/utils_test.go @@ -42,11 +42,11 @@ func TestIsClosed(t *testing.T) { channel := make(chan bool) - assert.Equal(t, false, isClosed(channel)) + assert.False(t, isClosed(channel)) close(channel) - assert.Equal(t, true, isClosed(channel)) + assert.True(t, isClosed(channel)) } diff --git a/receiver/awsecscontainermetricsreceiver/internal/awsecscontainermetrics/accumulator_test.go b/receiver/awsecscontainermetricsreceiver/internal/awsecscontainermetrics/accumulator_test.go index 6f03a80f882e..f12c8bd15f2c 100644 --- a/receiver/awsecscontainermetricsreceiver/internal/awsecscontainermetrics/accumulator_test.go +++ b/receiver/awsecscontainermetricsreceiver/internal/awsecscontainermetrics/accumulator_test.go @@ -217,12 +217,12 @@ func TestGetMetricsDataCpuReservedZero(t *testing.T) { require.Less(t, 0, len(acc.mds)) } func TestIsEmptyStats(t *testing.T) { - require.EqualValues(t, false, isEmptyStats(&containerStats)) - require.EqualValues(t, true, isEmptyStats(cstats["002"])) + require.False(t, isEmptyStats(&containerStats)) + require.True(t, isEmptyStats(cstats["002"])) cstats = map[string]*ContainerStats{"001": nil} - require.EqualValues(t, true, isEmptyStats(cstats["001"])) + require.True(t, isEmptyStats(cstats["001"])) cstats = map[string]*ContainerStats{"001": {}} - require.EqualValues(t, true, isEmptyStats(cstats["001"])) + require.True(t, isEmptyStats(cstats["001"])) } func TestCalculateDuration(t *testing.T) { diff --git a/receiver/awsecscontainermetricsreceiver/internal/awsecscontainermetrics/resource_test.go b/receiver/awsecscontainermetricsreceiver/internal/awsecscontainermetrics/resource_test.go index 004805937495..2dcf2129c6b7 100644 --- a/receiver/awsecscontainermetricsreceiver/internal/awsecscontainermetrics/resource_test.go +++ b/receiver/awsecscontainermetricsreceiver/internal/awsecscontainermetrics/resource_test.go @@ -64,7 +64,7 @@ func TestContainerResourceForStoppedContainer(t *testing.T) { require.NotNil(t, r) attrMap := r.Attributes() getExitCodeAd, found := attrMap.Get(attributeContainerExitCode) - require.EqualValues(t, true, found) + require.True(t, found) require.EqualValues(t, 2, getExitCodeAd.Int()) require.EqualValues(t, 11, attrMap.Len()) expected := map[string]string{ @@ -165,7 +165,7 @@ func TestTaskResourceWithClusterARN(t *testing.T) { func verifyAttributeMap(t *testing.T, expected map[string]string, found pcommon.Map) { for key, val := range expected { attributeVal, found := found.Get(key) - require.EqualValues(t, true, found) + require.True(t, found) require.EqualValues(t, val, attributeVal.Str()) } diff --git a/receiver/bigipreceiver/client_test.go b/receiver/bigipreceiver/client_test.go index 417a06aca706..4bf162a75135 100644 --- a/receiver/bigipreceiver/client_test.go +++ b/receiver/bigipreceiver/client_test.go @@ -118,7 +118,7 @@ func TestGetNewToken(t *testing.T) { err := tc.GetNewToken(context.Background()) require.EqualError(t, err, "non 200 code returned 401") hasToken := tc.HasToken() - require.Equal(t, hasToken, false) + require.False(t, hasToken) }, }, { @@ -136,7 +136,7 @@ func TestGetNewToken(t *testing.T) { err := tc.GetNewToken(context.Background()) require.Contains(t, err.Error(), "failed to decode response payload") hasToken := tc.HasToken() - require.Equal(t, hasToken, false) + require.False(t, hasToken) }, }, { @@ -156,7 +156,7 @@ func TestGetNewToken(t *testing.T) { err := tc.GetNewToken(context.Background()) require.NoError(t, err) hasToken := tc.HasToken() - require.Equal(t, hasToken, true) + require.True(t, hasToken) }, }, } diff --git a/receiver/datadogreceiver/receiver_test.go b/receiver/datadogreceiver/receiver_test.go index 2f5bab833494..526b8967fccc 100644 --- a/receiver/datadogreceiver/receiver_test.go +++ b/receiver/datadogreceiver/receiver_test.go @@ -308,7 +308,7 @@ func TestDatadogMetricsV1_EndToEnd(t *testing.T) { assert.Equal(t, pmetric.MetricTypeSum, metric.Type()) assert.Equal(t, "system.load.1", metric.Name()) assert.Equal(t, pmetric.AggregationTemporalityDelta, metric.Sum().AggregationTemporality()) - assert.Equal(t, false, metric.Sum().IsMonotonic()) + assert.False(t, metric.Sum().IsMonotonic()) assert.Equal(t, pcommon.Timestamp(1636629071*1_000_000_000), metric.Sum().DataPoints().At(0).Timestamp()) assert.Equal(t, 0.7, metric.Sum().DataPoints().At(0).DoubleValue()) expectedEnvironment, _ := metric.Sum().DataPoints().At(0).Attributes().Get("environment") @@ -386,7 +386,7 @@ func TestDatadogMetricsV2_EndToEnd(t *testing.T) { assert.Equal(t, pmetric.MetricTypeSum, metric.Type()) assert.Equal(t, "system.load.1", metric.Name()) assert.Equal(t, pmetric.AggregationTemporalityDelta, metric.Sum().AggregationTemporality()) - assert.Equal(t, false, metric.Sum().IsMonotonic()) + assert.False(t, metric.Sum().IsMonotonic()) assert.Equal(t, pcommon.Timestamp(1636629071*1_000_000_000), metric.Sum().DataPoints().At(0).Timestamp()) assert.Equal(t, 1.5, metric.Sum().DataPoints().At(0).DoubleValue()) assert.Equal(t, pcommon.Timestamp(0), metric.Sum().DataPoints().At(0).StartTimestamp()) diff --git a/receiver/k8seventsreceiver/k8s_event_to_logdata_test.go b/receiver/k8seventsreceiver/k8s_event_to_logdata_test.go index 85a00e44019f..7b0a84a7d163 100644 --- a/receiver/k8seventsreceiver/k8s_event_to_logdata_test.go +++ b/receiver/k8seventsreceiver/k8s_event_to_logdata_test.go @@ -35,11 +35,11 @@ func TestK8sEventToLogDataWithApiAndResourceVersion(t *testing.T) { ld := k8sEventToLogData(zap.NewNop(), k8sEvent) attrs := ld.ResourceLogs().At(0).Resource().Attributes() attr, ok := attrs.Get("k8s.object.api_version") - assert.Equal(t, true, ok) + assert.True(t, ok) assert.Equal(t, "v1", attr.AsString()) attr, ok = attrs.Get("k8s.object.resource_version") - assert.Equal(t, true, ok) + assert.True(t, ok) assert.Equal(t, "", attr.AsString()) // add ResourceVersion @@ -47,7 +47,7 @@ func TestK8sEventToLogDataWithApiAndResourceVersion(t *testing.T) { ld = k8sEventToLogData(zap.NewNop(), k8sEvent) attrs = ld.ResourceLogs().At(0).Resource().Attributes() attr, ok = attrs.Get("k8s.object.resource_version") - assert.Equal(t, true, ok) + assert.True(t, ok) assert.Equal(t, "7387066320", attr.AsString()) } diff --git a/receiver/k8seventsreceiver/receiver_test.go b/receiver/k8seventsreceiver/receiver_test.go index f096d00c68e1..88d00b204e89 100644 --- a/receiver/k8seventsreceiver/receiver_test.go +++ b/receiver/k8seventsreceiver/receiver_test.go @@ -118,15 +118,15 @@ func TestAllowEvent(t *testing.T) { k8sEvent := getEvent() shouldAllowEvent := recv.allowEvent(k8sEvent) - assert.Equal(t, shouldAllowEvent, true) + assert.True(t, shouldAllowEvent) k8sEvent.FirstTimestamp = v1.Time{Time: time.Now().Add(-time.Hour)} shouldAllowEvent = recv.allowEvent(k8sEvent) - assert.Equal(t, shouldAllowEvent, false) + assert.False(t, shouldAllowEvent) k8sEvent.FirstTimestamp = v1.Time{} shouldAllowEvent = recv.allowEvent(k8sEvent) - assert.Equal(t, shouldAllowEvent, false) + assert.False(t, shouldAllowEvent) } func getEvent() *corev1.Event { diff --git a/receiver/k8sobjectsreceiver/unstructured_to_logdata_test.go b/receiver/k8sobjectsreceiver/unstructured_to_logdata_test.go index 5735e6d084cb..56623eecadd8 100644 --- a/receiver/k8sobjectsreceiver/unstructured_to_logdata_test.go +++ b/receiver/k8sobjectsreceiver/unstructured_to_logdata_test.go @@ -86,7 +86,7 @@ func TestUnstructuredListToLogData(t *testing.T) { resourceAttributes := rl.Resource().Attributes() logRecords := rl.ScopeLogs().At(0).LogRecords() _, ok := resourceAttributes.Get(semconv.AttributeK8SNamespaceName) - assert.Equal(t, ok, false) + assert.False(t, ok) assert.Equal(t, rl.ScopeLogs().Len(), 1) assert.Equal(t, logRecords.Len(), 3) diff --git a/receiver/kafkametricsreceiver/broker_scraper_test.go b/receiver/kafkametricsreceiver/broker_scraper_test.go index b506bfdee400..590454bb8b80 100644 --- a/receiver/kafkametricsreceiver/broker_scraper_test.go +++ b/receiver/kafkametricsreceiver/broker_scraper_test.go @@ -110,7 +110,7 @@ func TestBrokerScraper_empty_resource_attribute(t *testing.T) { require.Equal(t, 1, md.ResourceMetrics().Len()) require.Equal(t, 1, md.ResourceMetrics().At(0).ScopeMetrics().Len()) _, ok := md.ResourceMetrics().At(0).Resource().Attributes().Get("kafka.cluster.alias") - require.Equal(t, false, ok) + require.False(t, ok) } func TestBrokerScraper_scrape(t *testing.T) { diff --git a/receiver/kafkareceiver/header_extraction_test.go b/receiver/kafkareceiver/header_extraction_test.go index 01e84538ea15..c2dacfff103f 100644 --- a/receiver/kafkareceiver/header_extraction_test.go +++ b/receiver/kafkareceiver/header_extraction_test.go @@ -215,6 +215,6 @@ func TestHeaderExtractionMetrics(t *testing.T) { func validateHeader(t *testing.T, rs pcommon.Resource, headerKey string, headerValue string) { val, ok := rs.Attributes().Get(headerKey) - assert.Equal(t, ok, true) + assert.True(t, ok) assert.Equal(t, val.Str(), headerValue) } diff --git a/receiver/prometheusreceiver/config_test.go b/receiver/prometheusreceiver/config_test.go index 36fa893baf1e..70d519c55549 100644 --- a/receiver/prometheusreceiver/config_test.go +++ b/receiver/prometheusreceiver/config_test.go @@ -43,8 +43,8 @@ func TestLoadConfig(t *testing.T) { r1 := cfg.(*Config) assert.Equal(t, r1.PrometheusConfig.ScrapeConfigs[0].JobName, "demo") assert.Equal(t, time.Duration(r1.PrometheusConfig.ScrapeConfigs[0].ScrapeInterval), 5*time.Second) - assert.Equal(t, r1.UseStartTimeMetric, true) - assert.Equal(t, r1.TrimMetricSuffixes, true) + assert.True(t, r1.UseStartTimeMetric) + assert.True(t, r1.TrimMetricSuffixes) assert.Equal(t, r1.StartTimeMetricRegex, "^(.+_)*process_start_time_seconds$") assert.True(t, r1.ReportExtraScrapeMetrics) diff --git a/receiver/prometheusreceiver/targetallocator/manager_test.go b/receiver/prometheusreceiver/targetallocator/manager_test.go index 3845f75ab67d..7423bf109fc1 100644 --- a/receiver/prometheusreceiver/targetallocator/manager_test.go +++ b/receiver/prometheusreceiver/targetallocator/manager_test.go @@ -775,8 +775,8 @@ func TestConfigureSDHTTPClientConfigFromTA(t *testing.T) { assert.NoError(t, err) - assert.Equal(t, false, httpSD.HTTPClientConfig.FollowRedirects) - assert.Equal(t, true, httpSD.HTTPClientConfig.TLSConfig.InsecureSkipVerify) + assert.False(t, httpSD.HTTPClientConfig.FollowRedirects) + assert.True(t, httpSD.HTTPClientConfig.TLSConfig.InsecureSkipVerify) assert.Equal(t, "test.server", httpSD.HTTPClientConfig.TLSConfig.ServerName) assert.Equal(t, "/path/to/ca", httpSD.HTTPClientConfig.TLSConfig.CAFile) assert.Equal(t, "/path/to/cert", httpSD.HTTPClientConfig.TLSConfig.CertFile) diff --git a/receiver/snmpreceiver/otel_metric_helper_test.go b/receiver/snmpreceiver/otel_metric_helper_test.go index 2e88cecebb59..3a4332ba2bb7 100644 --- a/receiver/snmpreceiver/otel_metric_helper_test.go +++ b/receiver/snmpreceiver/otel_metric_helper_test.go @@ -113,7 +113,7 @@ func TestCreateResource(t *testing.T) { actual := helper.createResource("r1", map[string]string{"key1": "val1"}) require.NotNil(t, actual) val, exists := actual.Resource().Attributes().Get("key1") - require.Equal(t, true, exists) + require.True(t, exists) require.Equal(t, "val1", val.AsString()) require.Equal(t, actual, helper.resourcesByKey["r1"]) }, @@ -248,7 +248,7 @@ func TestCreateMetric(t *testing.T) { require.NotNil(t, actual) require.Equal(t, "description", actual.Description()) require.Equal(t, pmetric.AggregationTemporalityDelta, actual.Sum().AggregationTemporality()) - require.Equal(t, false, actual.Sum().IsMonotonic()) + require.False(t, actual.Sum().IsMonotonic()) require.Equal(t, "m1", actual.Name()) require.Equal(t, "1", actual.Unit()) require.Equal(t, actual, helper.metricsByResource["r1"]["m1"]) @@ -345,7 +345,7 @@ func TestAddMetricDataPoint(t *testing.T) { require.NoError(t, err) require.Equal(t, data.value, actual.IntValue()) val, exists := actual.Attributes().Get("key1") - require.Equal(t, true, exists) + require.True(t, exists) require.Equal(t, "val1", val.AsString()) metricDataPoint := metric.Gauge().DataPoints().At(0) require.Equal(t, &metricDataPoint, actual) @@ -385,7 +385,7 @@ func TestAddMetricDataPoint(t *testing.T) { require.NoError(t, err) require.Equal(t, data.value, actual.DoubleValue()) val, exists := actual.Attributes().Get("key1") - require.Equal(t, true, exists) + require.True(t, exists) require.Equal(t, "val1", val.AsString()) metricDataPoint := metric.Sum().DataPoints().At(0) require.Equal(t, &metricDataPoint, actual) @@ -421,7 +421,7 @@ func TestAddMetricDataPoint(t *testing.T) { require.NoError(t, err) require.Equal(t, int64(10), actual.IntValue()) val, exists := actual.Attributes().Get("key1") - require.Equal(t, true, exists) + require.True(t, exists) require.Equal(t, "val1", val.AsString()) metricDataPoint := metric.Gauge().DataPoints().At(0) require.Equal(t, &metricDataPoint, actual) @@ -457,7 +457,7 @@ func TestAddMetricDataPoint(t *testing.T) { require.NoError(t, err) require.Equal(t, float64(10.0), actual.DoubleValue()) val, exists := actual.Attributes().Get("key1") - require.Equal(t, true, exists) + require.True(t, exists) require.Equal(t, "val1", val.AsString()) metricDataPoint := metric.Gauge().DataPoints().At(0) require.Equal(t, &metricDataPoint, actual) diff --git a/receiver/solacereceiver/unmarshaller_receive_test.go b/receiver/solacereceiver/unmarshaller_receive_test.go index cfda03246474..992caffb8651 100644 --- a/receiver/solacereceiver/unmarshaller_receive_test.go +++ b/receiver/solacereceiver/unmarshaller_receive_test.go @@ -762,7 +762,7 @@ func TestReceiveUnmarshallerInsertUserProperty(t *testing.T) { &receive_v1.SpanData_UserPropertyValue_BoolValue{BoolValue: true}, pcommon.ValueTypeBool, func(val pcommon.Value) { - assert.Equal(t, true, val.Bool()) + assert.True(t, val.Bool()) }, }, {