1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-03-29 21:47:00 +02:00

[chore]: enable error-is-as rule from testifylint (#5836)

Testifylint is a linter that provides best practices with the use of
testify.

This PR enables
[error-is-as](https://github.com/Antonboom/testifylint?tab=readme-ov-file#error-is-as)
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-24 19:17:16 +02:00 committed by GitHub
parent 6731dc7090
commit 62cc0c7441
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 9 additions and 18 deletions

View File

@ -306,7 +306,6 @@ linters-settings:
testifylint: testifylint:
enable-all: true enable-all: true
disable: disable:
- error-is-as
- error-nil - error-nil
- expected-actual - expected-actual
- float-compare - float-compare

View File

@ -5,7 +5,6 @@ package opentracing
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"net/http" "net/http"
"reflect" "reflect"
@ -66,7 +65,7 @@ func TestTextMapWrapper_New(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
_, err = newTextMapWrapperForExtract(newTestOnlyTextMapWriter()) _, err = newTextMapWrapperForExtract(newTestOnlyTextMapWriter())
assert.True(t, errors.Is(err, ot.ErrInvalidCarrier)) assert.ErrorIs(t, err, ot.ErrInvalidCarrier)
_, err = newTextMapWrapperForExtract(newTestTextMapReaderAndWriter()) _, err = newTextMapWrapperForExtract(newTestTextMapReaderAndWriter())
assert.NoError(t, err) assert.NoError(t, err)
@ -75,7 +74,7 @@ func TestTextMapWrapper_New(t *testing.T) {
assert.NoError(t, err) assert.NoError(t, err)
_, err = newTextMapWrapperForInject(newTestOnlyTextMapReader()) _, err = newTextMapWrapperForInject(newTestOnlyTextMapReader())
assert.True(t, errors.Is(err, ot.ErrInvalidCarrier)) assert.ErrorIs(t, err, ot.ErrInvalidCarrier)
_, err = newTextMapWrapperForInject(newTestTextMapReaderAndWriter()) _, err = newTextMapWrapperForInject(newTestTextMapReaderAndWriter())
assert.NoError(t, err) assert.NoError(t, err)

View File

@ -7,7 +7,6 @@
package internal package internal
import ( import (
"errors"
"strings" "strings"
"testing" "testing"
@ -18,7 +17,7 @@ func requireErrorString(t *testing.T, expect string, err error) {
t.Helper() t.Helper()
require.NotNil(t, err) require.NotNil(t, err)
require.Error(t, err) require.Error(t, err)
require.True(t, errors.Is(err, PartialSuccess{})) require.ErrorIs(t, err, PartialSuccess{})
const pfx = "OTLP partial success: " const pfx = "OTLP partial success: "

View File

@ -7,7 +7,6 @@
package internal package internal
import ( import (
"errors"
"strings" "strings"
"testing" "testing"
@ -18,7 +17,7 @@ func requireErrorString(t *testing.T, expect string, err error) {
t.Helper() t.Helper()
require.NotNil(t, err) require.NotNil(t, err)
require.Error(t, err) require.Error(t, err)
require.True(t, errors.Is(err, PartialSuccess{})) require.ErrorIs(t, err, PartialSuccess{})
const pfx = "OTLP partial success: " const pfx = "OTLP partial success: "

View File

@ -5,7 +5,6 @@ package otlptrace_test
import ( import (
"context" "context"
"errors"
"strings" "strings"
"testing" "testing"
@ -45,7 +44,7 @@ func TestExporterClientError(t *testing.T) {
err = exp.ExportSpans(ctx, spans) err = exp.ExportSpans(ctx, spans)
assert.Error(t, err) assert.Error(t, err)
assert.True(t, errors.Is(err, context.Canceled)) assert.ErrorIs(t, err, context.Canceled)
assert.True(t, strings.HasPrefix(err.Error(), "traces export: "), err) assert.True(t, strings.HasPrefix(err.Error(), "traces export: "), err)
assert.NoError(t, exp.Shutdown(ctx)) assert.NoError(t, exp.Shutdown(ctx))

View File

@ -7,7 +7,6 @@
package internal package internal
import ( import (
"errors"
"strings" "strings"
"testing" "testing"
@ -18,7 +17,7 @@ func requireErrorString(t *testing.T, expect string, err error) {
t.Helper() t.Helper()
require.NotNil(t, err) require.NotNil(t, err)
require.Error(t, err) require.Error(t, err)
require.True(t, errors.Is(err, PartialSuccess{})) require.ErrorIs(t, err, PartialSuccess{})
const pfx = "OTLP partial success: " const pfx = "OTLP partial success: "

View File

@ -7,7 +7,6 @@
package internal package internal
import ( import (
"errors"
"strings" "strings"
"testing" "testing"
@ -18,7 +17,7 @@ func requireErrorString(t *testing.T, expect string, err error) {
t.Helper() t.Helper()
require.NotNil(t, err) require.NotNil(t, err)
require.Error(t, err) require.Error(t, err)
require.True(t, errors.Is(err, PartialSuccess{})) require.ErrorIs(t, err, PartialSuccess{})
const pfx = "OTLP partial success: " const pfx = "OTLP partial success: "

View File

@ -7,7 +7,6 @@
package internal package internal
import ( import (
"errors"
"strings" "strings"
"testing" "testing"
@ -18,7 +17,7 @@ func requireErrorString(t *testing.T, expect string, err error) {
t.Helper() t.Helper()
require.NotNil(t, err) require.NotNil(t, err)
require.Error(t, err) require.Error(t, err)
require.True(t, errors.Is(err, PartialSuccess{})) require.ErrorIs(t, err, PartialSuccess{})
const pfx = "OTLP partial success: " const pfx = "OTLP partial success: "

View File

@ -5,7 +5,6 @@ package resource_test
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"testing" "testing"
@ -20,7 +19,7 @@ func TestBuiltinStringDetector(t *testing.T) {
res, err := resource.StringDetector("", attribute.Key("K"), func() (string, error) { res, err := resource.StringDetector("", attribute.Key("K"), func() (string, error) {
return "", E return "", E
}).Detect(context.Background()) }).Detect(context.Background())
require.True(t, errors.Is(err, E)) require.ErrorIs(t, err, E)
require.NotEqual(t, E, err) require.NotEqual(t, E, err)
require.Nil(t, res) require.Nil(t, res)
} }