Skip to content

Commit

Permalink
Merge pull request #18740 from ghouscht/testifylint-error-is-as
Browse files Browse the repository at this point in the history
fix: enable error-is-as rule from testifylint
  • Loading branch information
ahrtr authored Oct 16, 2024
2 parents 6779a89 + 499196d commit ac3d5d7
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/expect/expect.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (ep *ExpectProcess) ExpectFunc(ctx context.Context, f func(string) bool) (s

select {
case <-ctx.Done():
return "", fmt.Errorf("context done before matching log found")
return "", fmt.Errorf("context done before matching log found: %w", ctx.Err())
case <-time.After(time.Millisecond * 10):
// continue loop
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/expect/expect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestExpectFuncTimeout(t *testing.T) {

_, err = ep.ExpectFunc(ctx, func(a string) bool { return false })

require.ErrorAs(t, err, &context.DeadlineExceeded)
require.ErrorIs(t, err, context.DeadlineExceeded)

if err = ep.Stop(); err != nil {
t.Fatal(err)
Expand Down
3 changes: 1 addition & 2 deletions tests/framework/testutils/log_observer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package testutils

import (
"context"
"errors"
"fmt"
"strings"
"testing"
Expand All @@ -36,7 +35,7 @@ func TestLogObserver_Timeout(t *testing.T) {
ctx, cancel := context.WithTimeout(context.TODO(), 100*time.Millisecond)
_, err := logOb.Expect(ctx, "unknown", 1)
cancel()
assert.True(t, errors.Is(err, context.DeadlineExceeded))
assert.ErrorIs(t, err, context.DeadlineExceeded)

assert.Len(t, logOb.entries, 1)
}
Expand Down
1 change: 0 additions & 1 deletion tools/.golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ linters-settings: # please keep this alphabetized
- ST1019 # Importing the same package multiple times.
testifylint:
disable:
- error-is-as
- error-nil
- expected-actual
- float-compare
Expand Down

0 comments on commit ac3d5d7

Please sign in to comment.