Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore]: enable expected-actual rule from testifylint #5848

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ linters-settings:
testifylint:
enable-all: true
disable:
- expected-actual
- float-compare
- go-require
- negative-positive
Expand Down
6 changes: 3 additions & 3 deletions baggage/baggage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ func TestBaggageParseValue(t *testing.T) {

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

assert.EqualValues(t, val, tc.valueWant)
assert.EqualValues(t, tc.valueWant, val)
assert.Equal(t, len(val), tc.valueWantSize)
assert.True(t, utf8.ValidString(val))
})
Expand Down Expand Up @@ -1135,12 +1135,12 @@ func TestMemberString(t *testing.T) {
// normal key value pair
member, _ := NewMemberRaw("key", "value")
memberStr := member.String()
assert.Equal(t, memberStr, "key=value")
assert.Equal(t, "key=value", memberStr)

// encoded value
member, _ = NewMemberRaw("key", "; ")
memberStr = member.String()
assert.Equal(t, memberStr, "key=%3B%20")
assert.Equal(t, "key=%3B%20", memberStr)
}

var benchBaggage Baggage
Expand Down
2 changes: 1 addition & 1 deletion bridge/opencensus/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ func TestNewTraceBridge(t *testing.T) {
gotSpans := exporter.GetSpans()
require.Len(t, gotSpans, 1)
gotSpan := gotSpans[0]
assert.Equal(t, gotSpan.InstrumentationScope.Name, scopeName)
assert.Equal(t, scopeName, gotSpan.InstrumentationScope.Name)
assert.Equal(t, gotSpan.InstrumentationScope.Version, Version())
}
6 changes: 3 additions & 3 deletions bridge/opentracing/bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ func TestTextMapWrapper_action(t *testing.T) {
assert.Len(t, str, 2)
assert.Contains(t, str, "key1", "key2")

assert.Equal(t, carrier.Get("key1"), "val1")
assert.Equal(t, carrier.Get("key2"), "val2")
assert.Equal(t, "val1", carrier.Get("key1"))
assert.Equal(t, "val2", carrier.Get("key2"))
}

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

s := b.StartSpan(tc.name, tc.opt...)
assert.Equal(t, s.(*bridgeSpan).otelSpan.(*internal.MockSpan).SpanKind, tc.expected)
assert.Equal(t, tc.expected, s.(*bridgeSpan).otelSpan.(*internal.MockSpan).SpanKind)
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions exporters/otlp/otlplog/otlploghttp/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ func TestConfig(t *testing.T) {
got := coll.Headers()
require.Regexp(t, "OTel Go OTLP over HTTP/protobuf logs exporter/[01]\\..*", got)
require.Contains(t, got, key)
assert.Equal(t, got[key], []string{headers[key]})
assert.Equal(t, []string{headers[key]}, got[key])
})

t.Run("WithTimeout", func(t *testing.T) {
Expand Down Expand Up @@ -758,7 +758,7 @@ func TestConfig(t *testing.T) {

got := coll.Headers()
require.Contains(t, got, key)
assert.Equal(t, got[key], []string{headers[key]})
assert.Equal(t, []string{headers[key]}, got[key])
})

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

got := coll.Headers()
require.Contains(t, got, headerKeySetInProxy)
assert.Equal(t, got[headerKeySetInProxy], []string{headerValueSetInProxy})
assert.Equal(t, []string{headerValueSetInProxy}, got[headerKeySetInProxy])
})
}
2 changes: 1 addition & 1 deletion exporters/otlp/otlpmetric/otlpmetricgrpc/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func TestConfig(t *testing.T) {
got := coll.Headers()
require.Regexp(t, "OTel Go OTLP over gRPC metrics exporter/[01]\\..*", got)
require.Contains(t, got, key)
assert.Equal(t, got[key], []string{headers[key]})
assert.Equal(t, []string{headers[key]}, got[key])
})

t.Run("WithTimeout", func(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func TestConfigs(t *testing.T) {
"OTEL_EXPORTER_OTLP_TIMEOUT": "15000",
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, c.Metrics.Timeout, 15*time.Second)
assert.Equal(t, 15*time.Second, c.Metrics.Timeout)
},
},
{
Expand All @@ -434,7 +434,7 @@ func TestConfigs(t *testing.T) {
"OTEL_EXPORTER_OTLP_METRICS_TIMEOUT": "28000",
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, c.Metrics.Timeout, 28*time.Second)
assert.Equal(t, 28*time.Second, c.Metrics.Timeout)
},
},
{
Expand All @@ -447,7 +447,7 @@ func TestConfigs(t *testing.T) {
WithTimeout(5 * time.Second),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, c.Metrics.Timeout, 5*time.Second)
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)
},
},

Expand Down
6 changes: 3 additions & 3 deletions exporters/otlp/otlpmetric/otlpmetrichttp/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestConfig(t *testing.T) {
got := coll.Headers()
require.Regexp(t, "OTel Go OTLP over HTTP/protobuf metrics exporter/[01]\\..*", got)
require.Contains(t, got, key)
assert.Equal(t, got[key], []string{headers[key]})
assert.Equal(t, []string{headers[key]}, got[key])
})

t.Run("WithTimeout", func(t *testing.T) {
Expand Down Expand Up @@ -250,7 +250,7 @@ func TestConfig(t *testing.T) {

got := coll.Headers()
require.Contains(t, got, key)
assert.Equal(t, got[key], []string{headers[key]})
assert.Equal(t, []string{headers[key]}, got[key])
})

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

got := coll.Headers()
require.Contains(t, got, headerKeySetInProxy)
assert.Equal(t, got[headerKeySetInProxy], []string{headerValueSetInProxy})
assert.Equal(t, []string{headerValueSetInProxy}, got[headerKeySetInProxy])
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func TestConfigs(t *testing.T) {
"OTEL_EXPORTER_OTLP_TIMEOUT": "15000",
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, c.Metrics.Timeout, 15*time.Second)
assert.Equal(t, 15*time.Second, c.Metrics.Timeout)
},
},
{
Expand All @@ -434,7 +434,7 @@ func TestConfigs(t *testing.T) {
"OTEL_EXPORTER_OTLP_METRICS_TIMEOUT": "28000",
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, c.Metrics.Timeout, 28*time.Second)
assert.Equal(t, 28*time.Second, c.Metrics.Timeout)
},
},
{
Expand All @@ -447,7 +447,7 @@ func TestConfigs(t *testing.T) {
WithTimeout(5 * time.Second),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, c.Metrics.Timeout, 5*time.Second)
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)
},
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ func TestConfigs(t *testing.T) {
"OTEL_EXPORTER_OTLP_TIMEOUT": "15000",
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, c.Traces.Timeout, 15*time.Second)
assert.Equal(t, 15*time.Second, c.Traces.Timeout)
},
},
{
Expand All @@ -430,7 +430,7 @@ func TestConfigs(t *testing.T) {
"OTEL_EXPORTER_OTLP_TRACES_TIMEOUT": "27000",
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, c.Traces.Timeout, 27*time.Second)
assert.Equal(t, 27*time.Second, c.Traces.Timeout)
},
},
{
Expand All @@ -443,7 +443,7 @@ func TestConfigs(t *testing.T) {
WithTimeout(5 * time.Second),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, c.Traces.Timeout, 5*time.Second)
assert.Equal(t, 5*time.Second, c.Traces.Timeout)
},
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ func TestConfigs(t *testing.T) {
"OTEL_EXPORTER_OTLP_TIMEOUT": "15000",
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, c.Traces.Timeout, 15*time.Second)
assert.Equal(t, 15*time.Second, c.Traces.Timeout)
},
},
{
Expand All @@ -430,7 +430,7 @@ func TestConfigs(t *testing.T) {
"OTEL_EXPORTER_OTLP_TRACES_TIMEOUT": "27000",
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, c.Traces.Timeout, 27*time.Second)
assert.Equal(t, 27*time.Second, c.Traces.Timeout)
},
},
{
Expand All @@ -443,7 +443,7 @@ func TestConfigs(t *testing.T) {
WithTimeout(5 * time.Second),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, c.Traces.Timeout, 5*time.Second)
assert.Equal(t, 5*time.Second, c.Traces.Timeout)
},
},

Expand Down
2 changes: 1 addition & 1 deletion exporters/prometheus/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ func TestExemplars(t *testing.T) {
}
}
require.NotNil(t, exemplar)
require.Equal(t, exemplar.GetValue(), tc.expectedExemplarValue)
require.Equal(t, tc.expectedExemplarValue, exemplar.GetValue())
expectedLabels := map[string]string{
traceIDExemplarKey: "01000000000000000000000000000000",
spanIDExemplarKey: "0100000000000000",
Expand Down
6 changes: 3 additions & 3 deletions internal/shared/otlp/otlpmetric/oconf/options_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func TestConfigs(t *testing.T) {
"OTEL_EXPORTER_OTLP_TIMEOUT": "15000",
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, c.Metrics.Timeout, 15*time.Second)
assert.Equal(t, 15*time.Second, c.Metrics.Timeout)
},
},
{
Expand All @@ -434,7 +434,7 @@ func TestConfigs(t *testing.T) {
"OTEL_EXPORTER_OTLP_METRICS_TIMEOUT": "28000",
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, c.Metrics.Timeout, 28*time.Second)
assert.Equal(t, 28*time.Second, c.Metrics.Timeout)
},
},
{
Expand All @@ -447,7 +447,7 @@ func TestConfigs(t *testing.T) {
WithTimeout(5 * time.Second),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, c.Metrics.Timeout, 5*time.Second)
assert.Equal(t, 5*time.Second, c.Metrics.Timeout)
},
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ func TestConfigs(t *testing.T) {
"OTEL_EXPORTER_OTLP_TIMEOUT": "15000",
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, c.Traces.Timeout, 15*time.Second)
assert.Equal(t, 15*time.Second, c.Traces.Timeout)
},
},
{
Expand All @@ -430,7 +430,7 @@ func TestConfigs(t *testing.T) {
"OTEL_EXPORTER_OTLP_TRACES_TIMEOUT": "27000",
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, c.Traces.Timeout, 27*time.Second)
assert.Equal(t, 27*time.Second, c.Traces.Timeout)
},
},
{
Expand All @@ -443,7 +443,7 @@ func TestConfigs(t *testing.T) {
WithTimeout(5 * time.Second),
},
asserts: func(t *testing.T, c *Config, grpcOption bool) {
assert.Equal(t, c.Traces.Timeout, 5*time.Second)
assert.Equal(t, 5*time.Second, c.Traces.Timeout)
},
},

Expand Down
4 changes: 2 additions & 2 deletions log/logtest/recorder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ func TestRecorderEmitAndReset(t *testing.T) {
ctx := context.Background()

l.Emit(ctx, r1)
assert.Equal(t, r.Result()[0].Records, []EmittedRecord{
assert.Equal(t, []EmittedRecord{
{r1, ctx},
})
}, r.Result()[0].Records)

nl := r.Logger("test")
assert.Empty(t, r.Result()[1].Records)
Expand Down
4 changes: 2 additions & 2 deletions log/noop/noop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func assertAllExportedMethodNoPanic(rVal reflect.Value, rType reflect.Type) func

func TestNewTracerProvider(t *testing.T) {
provider := NewLoggerProvider()
assert.Equal(t, provider, LoggerProvider{})
assert.Equal(t, LoggerProvider{}, provider)
logger := provider.Logger("")
assert.Equal(t, logger, Logger{})
assert.Equal(t, Logger{}, logger)
}
4 changes: 2 additions & 2 deletions metric/noop/noop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func assertAllExportedMethodNoPanic(rVal reflect.Value, rType reflect.Type) func

func TestNewMeterProvider(t *testing.T) {
mp := NewMeterProvider()
assert.Equal(t, mp, MeterProvider{})
assert.Equal(t, MeterProvider{}, mp)
meter := mp.Meter("")
assert.Equal(t, meter, Meter{})
assert.Equal(t, Meter{}, meter)
}
8 changes: 4 additions & 4 deletions propagation/propagation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,17 @@ func TestMapCarrierGet(t *testing.T) {
"baz": "qux",
}

assert.Equal(t, carrier.Get("foo"), "bar")
assert.Equal(t, carrier.Get("baz"), "qux")
assert.Equal(t, "bar", carrier.Get("foo"))
assert.Equal(t, "qux", carrier.Get("baz"))
}

func TestMapCarrierSet(t *testing.T) {
carrier := make(propagation.MapCarrier)
carrier.Set("foo", "bar")
carrier.Set("baz", "qux")

assert.Equal(t, carrier["foo"], "bar")
assert.Equal(t, carrier["baz"], "qux")
assert.Equal(t, "bar", carrier["foo"])
assert.Equal(t, "qux", carrier["baz"])
}

func TestMapCarrierKeys(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion sdk/log/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func TestQueue(t *testing.T) {
t.Run("newQueue", func(t *testing.T) {
const size = 1
q := newQueue(size)
assert.Equal(t, q.len, 0)
assert.Equal(t, 0, q.len)
assert.Equal(t, size, q.cap, "capacity")
assert.Equal(t, size, q.read.Len(), "read ring")
assert.Same(t, q.read, q.write, "different rings")
Expand Down
2 changes: 1 addition & 1 deletion sdk/log/ring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ func TestEmptyRing(t *testing.T) {
verifyRing(t, rPrev.Prev(), 1, 0)

var rLen, rDo *ring
assert.Equal(t, rLen.Len(), 0, "Len()")
assert.Equal(t, 0, rLen.Len(), "Len()")
rDo.Do(func(Record) { assert.Fail(t, "Do func arg called") })
}
2 changes: 1 addition & 1 deletion sdk/metric/meter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ func TestMeterCreatesInstrumentsValidations(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
m := NewMeterProvider().Meter("testInstruments")
err := tt.fn(t, m)
assert.Equal(t, err, tt.wantErr)
assert.Equal(t, tt.wantErr, err)
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/metric/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func TestLogConflictName(t *testing.T) {
)
} else {
assert.Equalf(
t, msg, "",
t, "", msg,
"warning logged for non-conflicting names: %s, %s",
tc.existing, tc.name,
)
Expand Down
2 changes: 1 addition & 1 deletion sdk/resource/os_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestUname(t *testing.T) {

uname, err := resource.Uname()

require.Equal(t, uname, "Mock OS DESKTOP-PC 5.0.0 #1 SMP Thu May 6 12:34:56 UTC 2021 x86_64")
require.Equal(t, "Mock OS DESKTOP-PC 5.0.0 #1 SMP Thu May 6 12:34:56 UTC 2021 x86_64", uname)
require.NoError(t, err)

resource.SetDefaultUnameProvider()
Expand Down
Loading
Loading