From e6274e3b6ea6e2f6cff6246768c2b4d453bf8fcc Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Sat, 30 Nov 2024 17:03:22 +0100 Subject: [PATCH] chore: enable testifylint linter Signed-off-by: Matthieu MOREL --- pkg/configresolver/config_resolver_test.go | 2 +- pkg/templates/danglinghpa/template_test.go | 3 +-- pkg/templates/hpareplicas/template_test.go | 4 +--- pkg/templates/templates_testutils.go | 2 ++ pkg/templates/util/value_in_range_test.go | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/configresolver/config_resolver_test.go b/pkg/configresolver/config_resolver_test.go index 38bfb46e7..e613b99b3 100644 --- a/pkg/configresolver/config_resolver_test.go +++ b/pkg/configresolver/config_resolver_test.go @@ -45,7 +45,7 @@ func TestIgnorePaths(t *testing.T) { } else { for _, path := range paths { assert.NoError(t, err) - assert.Equal(t, path, e.Expected) + assert.Equal(t, e.Expected, path) } } } diff --git a/pkg/templates/danglinghpa/template_test.go b/pkg/templates/danglinghpa/template_test.go index 05fbcfde2..f8c23c056 100644 --- a/pkg/templates/danglinghpa/template_test.go +++ b/pkg/templates/danglinghpa/template_test.go @@ -4,7 +4,6 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "golang.stackrox.io/kube-linter/pkg/diagnostic" "golang.stackrox.io/kube-linter/pkg/lintcontext/mocks" @@ -84,7 +83,7 @@ func (s *DanglingHpaSuite) addHpaWithTarget(name string, target objectReference, } }) default: - require.FailNow(s.T(), fmt.Sprintf("Unknown autoscaling version %s", version)) + s.Require().FailNow(fmt.Sprintf("Unknown autoscaling version %s", version)) } } diff --git a/pkg/templates/hpareplicas/template_test.go b/pkg/templates/hpareplicas/template_test.go index 894aace00..71990d85f 100644 --- a/pkg/templates/hpareplicas/template_test.go +++ b/pkg/templates/hpareplicas/template_test.go @@ -4,8 +4,6 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" "golang.stackrox.io/kube-linter/pkg/diagnostic" "golang.stackrox.io/kube-linter/pkg/lintcontext/mocks" @@ -54,7 +52,7 @@ func (s *HPAReplicaTestSuite) addHPAWithReplicas(name string, replicas int32, ve hpa.Spec.MinReplicas = &replicas }) default: - require.FailNow(s.T(), fmt.Sprintf("Unknown autoscaling version %s", version)) + s.Require().FailNow(fmt.Sprintf("Unknown autoscaling version %s", version)) } } diff --git a/pkg/templates/templates_testutils.go b/pkg/templates/templates_testutils.go index e09c40e8b..7ea106e16 100644 --- a/pkg/templates/templates_testutils.go +++ b/pkg/templates/templates_testutils.go @@ -26,6 +26,7 @@ type TestCase struct { // Init initializes the test suite with a template func (s *TemplateTestSuite) Init(templateKey string) { + s.T().Helper() t, ok := Get(templateKey) s.True(ok, "template with key %q not found", templateKey) s.Template = t @@ -53,6 +54,7 @@ func (s *TemplateTestSuite) Validate( } func (s *TemplateTestSuite) compareDiagnostics(expected, actual []diagnostic.Diagnostic) { + s.T().Helper() expectedMessages, actualMessages := make([]string, 0, len(expected)), make([]string, 0, len(actual)) for _, diag := range expected { expectedMessages = append(expectedMessages, diag.Message) diff --git a/pkg/templates/util/value_in_range_test.go b/pkg/templates/util/value_in_range_test.go index 1bd14960b..336c17963 100644 --- a/pkg/templates/util/value_in_range_test.go +++ b/pkg/templates/util/value_in_range_test.go @@ -77,7 +77,7 @@ func TestValueInRange(t *testing.T) { } { c := testCase t.Run(fmt.Sprintf("%+v", c), func(t *testing.T) { - assert.Equal(t, ValueInRange(c.value, c.lowerBound, c.upperBound), c.expectedMatch) + assert.Equal(t, c.expectedMatch, ValueInRange(c.value, c.lowerBound, c.upperBound)) }) } }