Skip to content

Commit

Permalink
testifylint: enable bool-compare, compares, require-error (#2486)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
  • Loading branch information
mmorel-35 authored Jan 23, 2024
1 parent 95f4c10 commit 9359b78
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion internal/cmd/egctl/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func TestLabelSelectorBadInput(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
labelSelectors = tc.labels
_, err := retrieveConfigDump(tc.args, false, AllEnvoyConfigType)
assert.Error(t, err, "error not found")
require.Error(t, err, "error not found")
})
}
}
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/egctl/translate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/yaml"
Expand Down Expand Up @@ -320,7 +319,7 @@ func TestTranslate(t *testing.T) {
if tc.expect {
require.NoError(t, root.ExecuteContext(context.Background()))
} else {
assert.Error(t, root.ExecuteContext(context.Background()))
require.Error(t, root.ExecuteContext(context.Background()))
return
}

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestGetConfigValidate(t *testing.T) {
require.NoError(t, err)
} else {
for _, e := range test.errors {
assert.ErrorContains(t, err, e)
require.ErrorContains(t, err, e)
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion internal/gatewayapi/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ func TestIsValidHostname(t *testing.T) {
if tc.err == "" {
require.NoError(t, err)
} else {
assert.EqualError(t, err, tc.err)
require.EqualError(t, err, tc.err)
}
})
}
Expand Down
10 changes: 5 additions & 5 deletions internal/ir/xds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ func TestValidateXds(t *testing.T) {
} else {
got := test.input.Validate()
for _, w := range test.want {
assert.ErrorContains(t, got, w.Error())
require.ErrorContains(t, got, w.Error())
}
}
})
Expand Down Expand Up @@ -576,7 +576,7 @@ func TestValidateHTTPListener(t *testing.T) {
} else {
got := test.input.Validate()
for _, w := range test.want {
assert.ErrorContains(t, got, w.Error())
require.ErrorContains(t, got, w.Error())
}
}
})
Expand Down Expand Up @@ -623,7 +623,7 @@ func TestValidateTCPListener(t *testing.T) {
} else {
got := test.input.Validate()
for _, w := range test.want {
assert.ErrorContains(t, got, w.Error())
require.ErrorContains(t, got, w.Error())
}
}
})
Expand Down Expand Up @@ -783,7 +783,7 @@ func TestValidateUDPListener(t *testing.T) {
} else {
got := test.input.Validate()
for _, w := range test.want {
assert.ErrorContains(t, got, w.Error())
require.ErrorContains(t, got, w.Error())
}
}
})
Expand Down Expand Up @@ -935,7 +935,7 @@ func TestValidateHTTPRoute(t *testing.T) {
} else {
got := test.input.Validate()
for _, w := range test.want {
assert.ErrorContains(t, got, w.Error())
require.ErrorContains(t, got, w.Error())
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion internal/xds/server/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func TestTLSConfig(t *testing.T) {

go func() {
err := g.Serve(l)
assert.NoError(t, err)
require.NoError(t, err)
}()
defer g.GracefulStop()

Expand Down
6 changes: 3 additions & 3 deletions tools/linter/golangci-lint/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@ linters-settings:
disabled: true
testifylint:
disable:
- bool-compare
- compares
- float-compare
- go-require
- require-error
enable:
- bool-compare
- compares
- empty
- error-is-as
- error-nil
- expected-actual
- len
- require-error
- suite-dont-use-pkg
- suite-extra-assert-call
unparam:
Expand Down

0 comments on commit 9359b78

Please sign in to comment.