Skip to content

Commit d873f3d

Browse files
mmorel-35AkshayS198
authored andcommitted
[chore]: fix testifylint rules discovered with golangci-lint@v2 (open-telemetry#39271)
#### Description Fixes testifylint rules discovered with golangci-lint@v2 --------- Signed-off-by: Matthieu MOREL <[email protected]>
1 parent 30ba174 commit d873f3d

File tree

10 files changed

+16
-18
lines changed

10 files changed

+16
-18
lines changed

.golangci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,9 @@ linters:
198198

199199
testifylint:
200200
disable:
201-
- empty # FIXME
202201
- encoded-compare # has false positives that cannot be fixed with testifylint-fix
203202
- equal-values # FIXME
204203
- float-compare
205-
- formatter # FIXME
206-
- len # FIXME
207204
- require-error
208205
- suite-subtest-run
209206
- useless-assert # FIXME when golangci-lint > 2.0.2

exporter/signalfxexporter/internal/apm/requests/requestcounter/counter_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ func TestContextWithRequestCounter(t *testing.T) {
4646
todo := context.TODO()
4747
assert.False(t, counterExists(todo), "plain context shouldn't have a counter")
4848
assert.Equal(t, uint32(0), GetRequestCount(todo), "plain context should return count of 0")
49-
assert.NotPanics(t, func() { IncrementRequestCount(todo) }, todo, "incrementing a plain counter should not panic")
49+
assert.NotPanics(t, func() { IncrementRequestCount(todo) }, "incrementing a plain counter should not panic")
5050
assert.Equal(t, uint32(0), GetRequestCount(todo), "incrementing a plain counter should do nothing")
5151
}

exporter/sumologicexporter/sender_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ func TestSendCompressGzip(t *testing.T) {
987987
res.WriteHeader(http.StatusOK)
988988
if _, err := res.Write([]byte("")); err != nil {
989989
res.WriteHeader(http.StatusInternalServerError)
990-
assert.Fail(t, "err: %v", err)
990+
assert.Fail(t, err.Error())
991991
return
992992
}
993993
body := decodeGzip(t, req.Body)
@@ -1008,7 +1008,7 @@ func TestSendCompressGzipDeprecated(t *testing.T) {
10081008
res.WriteHeader(http.StatusOK)
10091009
if _, err := res.Write([]byte("")); err != nil {
10101010
res.WriteHeader(http.StatusInternalServerError)
1011-
assert.Fail(t, "err: %v", err)
1011+
assert.Fail(t, err.Error())
10121012
return
10131013
}
10141014
body := decodeGzip(t, req.Body)
@@ -1029,7 +1029,7 @@ func TestSendCompressZstd(t *testing.T) {
10291029
res.WriteHeader(http.StatusOK)
10301030
if _, err := res.Write([]byte("")); err != nil {
10311031
res.WriteHeader(http.StatusInternalServerError)
1032-
assert.Fail(t, "err: %v", err)
1032+
assert.Fail(t, err.Error())
10331033
return
10341034
}
10351035
body := decodeZstd(t, req.Body)
@@ -1050,7 +1050,7 @@ func TestSendCompressDeflate(t *testing.T) {
10501050
res.WriteHeader(http.StatusOK)
10511051
if _, err := res.Write([]byte("")); err != nil {
10521052
res.WriteHeader(http.StatusInternalServerError)
1053-
assert.Fail(t, "err: %v", err)
1053+
assert.Fail(t, err.Error())
10541054
return
10551055
}
10561056
body := decodeZlib(t, req.Body)

pkg/core/xidutils/big_endian_converter_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ func TestUInt64ToTraceIDConversion(t *testing.T) {
2727
assert.Equal(t,
2828
UInt64ToTraceID(5, 0),
2929
pcommon.TraceID([16]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}),
30-
UInt64ToTraceID(5, 0),
3130
"Failed to convert 0 low:")
3231
assert.Equal(t,
3332
pcommon.TraceID([16]byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05}),

pkg/stanza/operator/input/tcp/input_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package tcp
55

66
import (
77
"crypto/tls"
8+
"fmt"
89
"math/rand/v2"
910
"net"
1011
"os"
@@ -117,7 +118,7 @@ func tcpInputTest(input []byte, expected []string) func(t *testing.T) {
117118

118119
select {
119120
case entry := <-entryChan:
120-
require.FailNow(t, "Unexpected entry: %s", entry)
121+
require.FailNow(t, fmt.Sprintf("Unexpected entry: %s", entry))
121122
case <-time.After(100 * time.Millisecond):
122123
return
123124
}
@@ -183,7 +184,7 @@ func tcpInputAttributesTest(input []byte, expected []string) func(t *testing.T)
183184

184185
select {
185186
case entry := <-entryChan:
186-
require.FailNow(t, "Unexpected entry: %s", entry)
187+
require.FailNow(t, fmt.Sprintf("Unexpected entry: %s", entry))
187188
case <-time.After(100 * time.Millisecond):
188189
return
189190
}
@@ -254,7 +255,7 @@ func tlsInputTest(input []byte, expected []string) func(t *testing.T) {
254255

255256
select {
256257
case entry := <-entryChan:
257-
require.FailNow(t, "Unexpected entry: %s", entry)
258+
require.FailNow(t, fmt.Sprintf("Unexpected entry: %s", entry))
258259
case <-time.After(100 * time.Millisecond):
259260
return
260261
}

pkg/stanza/operator/input/udp/input_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package udp
55

66
import (
7+
"fmt"
78
"math/rand/v2"
89
"net"
910
"strconv"
@@ -61,7 +62,7 @@ func udpInputTest(input []byte, expected []string, cfg *Config) func(t *testing.
6162

6263
select {
6364
case entry := <-entryChan:
64-
require.FailNow(t, "Unexpected entry: %s", entry)
65+
require.FailNow(t, fmt.Sprintf("Unexpected entry: %s", entry))
6566
case <-time.After(100 * time.Millisecond):
6667
return
6768
}
@@ -131,7 +132,7 @@ func udpInputAttributesTest(input []byte, expected []string) func(t *testing.T)
131132

132133
select {
133134
case entry := <-entryChan:
134-
require.FailNow(t, "Unexpected entry: %s", entry)
135+
require.FailNow(t, fmt.Sprintf("Unexpected entry: %s", entry))
135136
case <-time.After(100 * time.Millisecond):
136137
return
137138
}

pkg/translator/prometheus/normalize_label_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
func TestSanitize(t *testing.T) {
1515
defer testutil.SetFeatureGateForTest(t, dropSanitizationGate, false)()
1616

17-
require.Empty(t, NormalizeLabel(""), "")
17+
require.Empty(t, NormalizeLabel(""))
1818
require.Equal(t, "key_test", NormalizeLabel("_test"))
1919
require.Equal(t, "key_0test", NormalizeLabel("0test"))
2020
require.Equal(t, "test", NormalizeLabel("test"))

processor/transformprocessor/internal/metrics/func_convert_exponential_hist_to_explicit_hist_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ func TestRandom_convert_exponential_hist_to_explicit_hist(t *testing.T) {
728728
// since the max value in the exponential histogram is 245
729729
// we can assert that the overflow bucket has a count > 0
730730
overflow := dp.BucketCounts().At(dp.BucketCounts().Len() - 1)
731-
assert.Positive(t, overflow, uint64(0), "overflow bucket count should be > 0")
731+
assert.Positive(t, overflow, "overflow bucket count should be > 0")
732732
return
733733
}
734734

receiver/awscontainerinsightreceiver/internal/host/ebsvolume_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func TestExtractEbsIDsUsedByKubernetes(t *testing.T) {
205205

206206
ebsIDs := e.extractEbsIDsUsedByKubernetes()
207207

208-
assert.Equal(t, test.expectedVolumeCount, len(ebsIDs))
208+
assert.Len(t, ebsIDs, test.expectedVolumeCount)
209209
if test.expectedVolumeCount > 0 {
210210
assert.Equal(t, test.expected, ebsIDs[test.devPath])
211211
}

receiver/tlscheckreceiver/scraper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func TestScrape_ExpiredEndpointCertificate(t *testing.T) {
145145

146146
// Ensure that timeLeft is negative for an expired cert
147147
timeLeft := dp.IntValue()
148-
assert.Negative(t, timeLeft, int64(0), "Time left should be negative for an expired certificate")
148+
assert.Negative(t, timeLeft, "Time left should be negative for an expired certificate")
149149
}
150150

151151
func TestScrape_NotYetValidEndpointCertificate(t *testing.T) {

0 commit comments

Comments
 (0)