Skip to content

Commit 6edc7a6

Browse files
authored
[chore]: enable expected-actual rule from testifylint (#5848)
Testifylint is a linter that provides best practices with the use of testify. This PR enables [expected-actual](https://github.com/Antonboom/testifylint?tab=readme-ov-file#expected-actual) rule from [testifylint](https://github.com/Antonboom/testifylint) Signed-off-by: Matthieu MOREL <[email protected]>
1 parent f710cec commit 6edc7a6

File tree

25 files changed

+62
-63
lines changed

25 files changed

+62
-63
lines changed

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ linters-settings:
306306
testifylint:
307307
enable-all: true
308308
disable:
309-
- expected-actual
310309
- float-compare
311310
- go-require
312311
- negative-positive

baggage/baggage_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ func TestBaggageParseValue(t *testing.T) {
597597

598598
val := b.Members()[0].Value()
599599

600-
assert.EqualValues(t, val, tc.valueWant)
600+
assert.EqualValues(t, tc.valueWant, val)
601601
assert.Equal(t, len(val), tc.valueWantSize)
602602
assert.True(t, utf8.ValidString(val))
603603
})
@@ -1135,12 +1135,12 @@ func TestMemberString(t *testing.T) {
11351135
// normal key value pair
11361136
member, _ := NewMemberRaw("key", "value")
11371137
memberStr := member.String()
1138-
assert.Equal(t, memberStr, "key=value")
1138+
assert.Equal(t, "key=value", memberStr)
11391139

11401140
// encoded value
11411141
member, _ = NewMemberRaw("key", "; ")
11421142
memberStr = member.String()
1143-
assert.Equal(t, memberStr, "key=%3B%20")
1143+
assert.Equal(t, "key=%3B%20", memberStr)
11441144
}
11451145

11461146
var benchBaggage Baggage

bridge/opencensus/trace_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ func TestNewTraceBridge(t *testing.T) {
2323
gotSpans := exporter.GetSpans()
2424
require.Len(t, gotSpans, 1)
2525
gotSpan := gotSpans[0]
26-
assert.Equal(t, gotSpan.InstrumentationScope.Name, scopeName)
26+
assert.Equal(t, scopeName, gotSpan.InstrumentationScope.Name)
2727
assert.Equal(t, gotSpan.InstrumentationScope.Version, Version())
2828
}

bridge/opentracing/bridge_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ func TestTextMapWrapper_action(t *testing.T) {
8686
assert.Len(t, str, 2)
8787
assert.Contains(t, str, "key1", "key2")
8888

89-
assert.Equal(t, carrier.Get("key1"), "val1")
90-
assert.Equal(t, carrier.Get("key2"), "val2")
89+
assert.Equal(t, "val1", carrier.Get("key1"))
90+
assert.Equal(t, "val2", carrier.Get("key2"))
9191
}
9292

9393
testInjectFunc := func(carrier propagation.TextMapCarrier) {
@@ -496,7 +496,7 @@ func Test_otTagsToOTelAttributesKindAndError(t *testing.T) {
496496
b, _ := NewTracerPair(tracer)
497497

498498
s := b.StartSpan(tc.name, tc.opt...)
499-
assert.Equal(t, s.(*bridgeSpan).otelSpan.(*internal.MockSpan).SpanKind, tc.expected)
499+
assert.Equal(t, tc.expected, s.(*bridgeSpan).otelSpan.(*internal.MockSpan).SpanKind)
500500
})
501501
}
502502
}

exporters/otlp/otlplog/otlploghttp/client_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ func TestConfig(t *testing.T) {
632632
got := coll.Headers()
633633
require.Regexp(t, "OTel Go OTLP over HTTP/protobuf logs exporter/[01]\\..*", got)
634634
require.Contains(t, got, key)
635-
assert.Equal(t, got[key], []string{headers[key]})
635+
assert.Equal(t, []string{headers[key]}, got[key])
636636
})
637637

638638
t.Run("WithTimeout", func(t *testing.T) {
@@ -758,7 +758,7 @@ func TestConfig(t *testing.T) {
758758

759759
got := coll.Headers()
760760
require.Contains(t, got, key)
761-
assert.Equal(t, got[key], []string{headers[key]})
761+
assert.Equal(t, []string{headers[key]}, got[key])
762762
})
763763

764764
t.Run("WithProxy", func(t *testing.T) {
@@ -776,6 +776,6 @@ func TestConfig(t *testing.T) {
776776

777777
got := coll.Headers()
778778
require.Contains(t, got, headerKeySetInProxy)
779-
assert.Equal(t, got[headerKeySetInProxy], []string{headerValueSetInProxy})
779+
assert.Equal(t, []string{headerValueSetInProxy}, got[headerKeySetInProxy])
780780
})
781781
}

exporters/otlp/otlpmetric/otlpmetricgrpc/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func TestConfig(t *testing.T) {
215215
got := coll.Headers()
216216
require.Regexp(t, "OTel Go OTLP over gRPC metrics exporter/[01]\\..*", got)
217217
require.Contains(t, got, key)
218-
assert.Equal(t, got[key], []string{headers[key]})
218+
assert.Equal(t, []string{headers[key]}, got[key])
219219
})
220220

221221
t.Run("WithTimeout", func(t *testing.T) {

exporters/otlp/otlpmetric/otlpmetricgrpc/internal/oconf/options_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ func TestConfigs(t *testing.T) {
424424
"OTEL_EXPORTER_OTLP_TIMEOUT": "15000",
425425
},
426426
asserts: func(t *testing.T, c *Config, grpcOption bool) {
427-
assert.Equal(t, c.Metrics.Timeout, 15*time.Second)
427+
assert.Equal(t, 15*time.Second, c.Metrics.Timeout)
428428
},
429429
},
430430
{
@@ -434,7 +434,7 @@ func TestConfigs(t *testing.T) {
434434
"OTEL_EXPORTER_OTLP_METRICS_TIMEOUT": "28000",
435435
},
436436
asserts: func(t *testing.T, c *Config, grpcOption bool) {
437-
assert.Equal(t, c.Metrics.Timeout, 28*time.Second)
437+
assert.Equal(t, 28*time.Second, c.Metrics.Timeout)
438438
},
439439
},
440440
{
@@ -447,7 +447,7 @@ func TestConfigs(t *testing.T) {
447447
WithTimeout(5 * time.Second),
448448
},
449449
asserts: func(t *testing.T, c *Config, grpcOption bool) {
450-
assert.Equal(t, c.Metrics.Timeout, 5*time.Second)
450+
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)
451451
},
452452
},
453453

exporters/otlp/otlpmetric/otlpmetrichttp/client_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func TestConfig(t *testing.T) {
124124
got := coll.Headers()
125125
require.Regexp(t, "OTel Go OTLP over HTTP/protobuf metrics exporter/[01]\\..*", got)
126126
require.Contains(t, got, key)
127-
assert.Equal(t, got[key], []string{headers[key]})
127+
assert.Equal(t, []string{headers[key]}, got[key])
128128
})
129129

130130
t.Run("WithTimeout", func(t *testing.T) {
@@ -250,7 +250,7 @@ func TestConfig(t *testing.T) {
250250

251251
got := coll.Headers()
252252
require.Contains(t, got, key)
253-
assert.Equal(t, got[key], []string{headers[key]})
253+
assert.Equal(t, []string{headers[key]}, got[key])
254254
})
255255

256256
t.Run("WithProxy", func(t *testing.T) {
@@ -268,6 +268,6 @@ func TestConfig(t *testing.T) {
268268

269269
got := coll.Headers()
270270
require.Contains(t, got, headerKeySetInProxy)
271-
assert.Equal(t, got[headerKeySetInProxy], []string{headerValueSetInProxy})
271+
assert.Equal(t, []string{headerValueSetInProxy}, got[headerKeySetInProxy])
272272
})
273273
}

exporters/otlp/otlpmetric/otlpmetrichttp/internal/oconf/options_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ func TestConfigs(t *testing.T) {
424424
"OTEL_EXPORTER_OTLP_TIMEOUT": "15000",
425425
},
426426
asserts: func(t *testing.T, c *Config, grpcOption bool) {
427-
assert.Equal(t, c.Metrics.Timeout, 15*time.Second)
427+
assert.Equal(t, 15*time.Second, c.Metrics.Timeout)
428428
},
429429
},
430430
{
@@ -434,7 +434,7 @@ func TestConfigs(t *testing.T) {
434434
"OTEL_EXPORTER_OTLP_METRICS_TIMEOUT": "28000",
435435
},
436436
asserts: func(t *testing.T, c *Config, grpcOption bool) {
437-
assert.Equal(t, c.Metrics.Timeout, 28*time.Second)
437+
assert.Equal(t, 28*time.Second, c.Metrics.Timeout)
438438
},
439439
},
440440
{
@@ -447,7 +447,7 @@ func TestConfigs(t *testing.T) {
447447
WithTimeout(5 * time.Second),
448448
},
449449
asserts: func(t *testing.T, c *Config, grpcOption bool) {
450-
assert.Equal(t, c.Metrics.Timeout, 5*time.Second)
450+
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)
451451
},
452452
},
453453

exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig/options_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ func TestConfigs(t *testing.T) {
420420
"OTEL_EXPORTER_OTLP_TIMEOUT": "15000",
421421
},
422422
asserts: func(t *testing.T, c *Config, grpcOption bool) {
423-
assert.Equal(t, c.Traces.Timeout, 15*time.Second)
423+
assert.Equal(t, 15*time.Second, c.Traces.Timeout)
424424
},
425425
},
426426
{
@@ -430,7 +430,7 @@ func TestConfigs(t *testing.T) {
430430
"OTEL_EXPORTER_OTLP_TRACES_TIMEOUT": "27000",
431431
},
432432
asserts: func(t *testing.T, c *Config, grpcOption bool) {
433-
assert.Equal(t, c.Traces.Timeout, 27*time.Second)
433+
assert.Equal(t, 27*time.Second, c.Traces.Timeout)
434434
},
435435
},
436436
{
@@ -443,7 +443,7 @@ func TestConfigs(t *testing.T) {
443443
WithTimeout(5 * time.Second),
444444
},
445445
asserts: func(t *testing.T, c *Config, grpcOption bool) {
446-
assert.Equal(t, c.Traces.Timeout, 5*time.Second)
446+
assert.Equal(t, 5*time.Second, c.Traces.Timeout)
447447
},
448448
},
449449

0 commit comments

Comments
 (0)