From fda7a43934078806726295d647955408923aef48 Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Fri, 31 Jan 2025 23:31:29 +0100 Subject: [PATCH] refactor: drop gotest.tools assertion and add linting rule use testify assertions and forbid different assertion libraries --- .golangci.yml | 4 ++ NOTICE.txt | 46 +++++++++---------- go.mod | 1 - .../outputs/elasticsearch/config_otel_test.go | 20 ++++---- 4 files changed, 37 insertions(+), 34 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 0fbcef63646a..c4ff00cc9092 100755 --- a/.golangci.yml +++ b/.golangci.yml @@ -125,6 +125,10 @@ linters-settings: - errors - fmt reason: "This package is deprecated, use `fmt.Errorf` with `%w` instead" + - gotest.tools/v3: + recommendations: + - github.com/stretchr/testify + reason: "Use one assertion library consistently across the codebase" - github.com/google/uuid: # Recommended modules that should be used instead. (Optional) recommendations: diff --git a/NOTICE.txt b/NOTICE.txt index f1784c76dc6d..284ea99049f0 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -28552,29 +28552,6 @@ Contents of probable licence file $GOMODCACHE/gotest.tools/gotestsum@v1.7.0/LICE limitations under the License. --------------------------------------------------------------------------------- -Dependency : gotest.tools/v3 -Version: v3.5.1 -Licence type (autodetected): Apache-2.0 --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/gotest.tools/v3@v3.5.1/LICENSE: - -Copyright 2018 gotest.tools authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - - -------------------------------------------------------------------------------- Dependency : howett.net/plist Version: v1.0.1 @@ -73800,6 +73777,29 @@ See the License for the specific language governing permissions and limitations under the License. +-------------------------------------------------------------------------------- +Dependency : gotest.tools/v3 +Version: v3.5.1 +Licence type (autodetected): Apache-2.0 +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/gotest.tools/v3@v3.5.1/LICENSE: + +Copyright 2018 gotest.tools authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + + -------------------------------------------------------------------------------- Dependency : k8s.io/klog/v2 Version: v2.130.1 diff --git a/go.mod b/go.mod index 88c0fabc38da..2198d1be7552 100644 --- a/go.mod +++ b/go.mod @@ -231,7 +231,6 @@ require ( golang.org/x/term v0.27.0 google.golang.org/genproto/googleapis/api v0.0.0-20241118233622-e639e219e697 gopkg.in/natefinch/lumberjack.v2 v2.2.1 - gotest.tools/v3 v3.5.1 ) require ( diff --git a/libbeat/otelbeat/oteltranslate/outputs/elasticsearch/config_otel_test.go b/libbeat/otelbeat/oteltranslate/outputs/elasticsearch/config_otel_test.go index 9b5fbd46f324..b5c673683834 100644 --- a/libbeat/otelbeat/oteltranslate/outputs/elasticsearch/config_otel_test.go +++ b/libbeat/otelbeat/oteltranslate/outputs/elasticsearch/config_otel_test.go @@ -22,10 +22,10 @@ import ( "fmt" "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/confmap" "gopkg.in/yaml.v2" - "gotest.tools/v3/assert" "github.com/elastic/elastic-agent-libs/config" ) @@ -72,7 +72,7 @@ timeout: 1m30s user: elastic headers: X-Header-1: foo - X-Bar-Header: bar + X-Bar-Header: bar batcher: enabled: true max_size_items: 1600 @@ -106,11 +106,11 @@ retry: enabled: true initial_interval: 1s max_interval: 1m0s - max_retries: 3 -logs_index: some-index + max_retries: 3 +logs_index: some-index password: changeme -user: elastic -timeout: 1m30s +user: elastic +timeout: 1m30s ` tests := []struct { @@ -147,11 +147,11 @@ retry: enabled: true initial_interval: 5s max_interval: 5m0s - max_retries: 3 -logs_index: some-index + max_retries: 3 +logs_index: some-index password: changeme -user: elastic -timeout: 1m30s +user: elastic +timeout: 1m30s idle_conn_timeout: 1s num_workers: 1 batcher: