1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-29 23:07:45 +02:00

[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 <matthieu.morel35@gmail.com>
This commit is contained in:
Matthieu MOREL
2024-09-26 12:04:33 +02:00
committed by GitHub
parent f710cecfc5
commit 6edc7a63df
25 changed files with 62 additions and 63 deletions

View File

@@ -216,7 +216,7 @@ func TestSpanIsRecording(t *testing.T) {
_, span := tp.Tracer(name).Start(context.Background(), "StartSpan")
got := span.IsRecording()
span.End()
assert.Equal(t, got, tc.want, name)
assert.Equal(t, tc.want, got, name)
}
})
@@ -1286,11 +1286,11 @@ func TestRecordErrorWithStackTrace(t *testing.T) {
instrumentationScope: instrumentation.Scope{Name: "RecordError"},
}
assert.Equal(t, got.spanContext, want.spanContext)
assert.Equal(t, got.parent, want.parent)
assert.Equal(t, got.name, want.name)
assert.Equal(t, got.status, want.status)
assert.Equal(t, got.spanKind, want.spanKind)
assert.Equal(t, want.spanContext, got.spanContext)
assert.Equal(t, want.parent, got.parent)
assert.Equal(t, want.name, got.name)
assert.Equal(t, want.status, got.status)
assert.Equal(t, want.spanKind, got.spanKind)
assert.Equal(t, got.events[0].Attributes[0].Value.AsString(), want.events[0].Attributes[0].Value.AsString())
assert.Equal(t, got.events[0].Attributes[1].Value.AsString(), want.events[0].Attributes[1].Value.AsString())
gotStackTraceFunctionName := strings.Split(got.events[0].Attributes[2].Value.AsString(), "\n")
@@ -1500,11 +1500,11 @@ func TestSpanCapturesPanic(t *testing.T) {
spans := te.Spans()
require.Len(t, spans, 1)
require.Len(t, spans[0].Events(), 1)
assert.Equal(t, spans[0].Events()[0].Name, semconv.ExceptionEventName)
assert.Equal(t, spans[0].Events()[0].Attributes, []attribute.KeyValue{
assert.Equal(t, semconv.ExceptionEventName, spans[0].Events()[0].Name)
assert.Equal(t, []attribute.KeyValue{
semconv.ExceptionType("*errors.errorString"),
semconv.ExceptionMessage("error message"),
})
}, spans[0].Events()[0].Attributes)
}
func TestSpanCapturesPanicWithStackTrace(t *testing.T) {
@@ -1523,9 +1523,9 @@ func TestSpanCapturesPanicWithStackTrace(t *testing.T) {
spans := te.Spans()
require.Len(t, spans, 1)
require.Len(t, spans[0].Events(), 1)
assert.Equal(t, spans[0].Events()[0].Name, semconv.ExceptionEventName)
assert.Equal(t, spans[0].Events()[0].Attributes[0].Value.AsString(), "*errors.errorString")
assert.Equal(t, spans[0].Events()[0].Attributes[1].Value.AsString(), "error message")
assert.Equal(t, semconv.ExceptionEventName, spans[0].Events()[0].Name)
assert.Equal(t, "*errors.errorString", spans[0].Events()[0].Attributes[0].Value.AsString())
assert.Equal(t, "error message", spans[0].Events()[0].Attributes[1].Value.AsString())
gotStackTraceFunctionName := strings.Split(spans[0].Events()[0].Attributes[2].Value.AsString(), "\n")
assert.Truef(t, strings.HasPrefix(gotStackTraceFunctionName[1], "go.opentelemetry.io/otel/sdk/trace.recordStackTrace"), "%q not prefixed with go.opentelemetry.io/otel/sdk/trace.recordStackTrace", gotStackTraceFunctionName[1])