From f42335c8af7cae4974d226f4613d7b484c28fb5c Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Sun, 1 Jun 2025 21:40:06 +0200 Subject: [PATCH] fix empty rule from testifylint Signed-off-by: Matthieu MOREL --- .golangci.yaml | 1 - pkg/cmd/cli/nodeagent/server_test.go | 4 ++-- pkg/cmd/util/flag/accessors_test.go | 2 +- pkg/cmd/util/flag/enum_test.go | 2 +- pkg/cmd/util/output/output_test.go | 2 +- pkg/install/resources_test.go | 4 ++-- pkg/repository/maintenance/maintenance_test.go | 12 ++++++------ pkg/repository/udmrepo/kopialib/lib_repo_test.go | 4 ++-- pkg/restic/command_test.go | 2 +- 9 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 0561290e4..74d3d3e2a 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -260,7 +260,6 @@ linters: testifylint: # TODO: enable them all disable: - - empty # FIXME - equal-values # FIXME - float-compare - go-require diff --git a/pkg/cmd/cli/nodeagent/server_test.go b/pkg/cmd/cli/nodeagent/server_test.go index 2551bfac3..96187636f 100644 --- a/pkg/cmd/cli/nodeagent/server_test.go +++ b/pkg/cmd/cli/nodeagent/server_test.go @@ -190,7 +190,7 @@ func Test_getDataPathConfigs(t *testing.T) { s.getDataPathConfigs() assert.Equal(t, test.expectConfigs, s.dataPathConfigs) if test.expectLog == "" { - assert.Equal(t, "", logBuffer) + assert.Empty(t, logBuffer) } else { assert.Contains(t, logBuffer, test.expectLog) } @@ -408,7 +408,7 @@ func Test_getDataPathConcurrentNum(t *testing.T) { num := s.getDataPathConcurrentNum(defaultNum) assert.Equal(t, test.expectNum, num) if test.expectLog == "" { - assert.Equal(t, "", logBuffer) + assert.Empty(t, logBuffer) } else { assert.Contains(t, logBuffer, test.expectLog) } diff --git a/pkg/cmd/util/flag/accessors_test.go b/pkg/cmd/util/flag/accessors_test.go index 280aab58d..1a6f5ed91 100644 --- a/pkg/cmd/util/flag/accessors_test.go +++ b/pkg/cmd/util/flag/accessors_test.go @@ -12,7 +12,7 @@ func TestGetOptionalStringFlag(t *testing.T) { // not specified cmd := &cobra.Command{} - assert.Equal(t, "", GetOptionalStringFlag(cmd, flagName)) + assert.Empty(t, GetOptionalStringFlag(cmd, flagName)) // specified cmd.Flags().String(flagName, "value", "") diff --git a/pkg/cmd/util/flag/enum_test.go b/pkg/cmd/util/flag/enum_test.go index 66230aa62..7b06a4d8d 100644 --- a/pkg/cmd/util/flag/enum_test.go +++ b/pkg/cmd/util/flag/enum_test.go @@ -22,7 +22,7 @@ func TestSetOfEnum(t *testing.T) { func TestTypeOfEnum(t *testing.T) { enum := NewEnum("a", "a", "b", "c") - assert.Equal(t, "", enum.Type()) + assert.Empty(t, enum.Type()) } func TestAllowedValuesOfEnum(t *testing.T) { diff --git a/pkg/cmd/util/output/output_test.go b/pkg/cmd/util/output/output_test.go index ba9c27843..d4d7fafc5 100644 --- a/pkg/cmd/util/output/output_test.go +++ b/pkg/cmd/util/output/output_test.go @@ -34,7 +34,7 @@ func TestClearOutputFlagDefault(t *testing.T) { BindFlags(cmd.Flags()) cmd.Flags().Set("output", "json") ClearOutputFlagDefault(cmd) - assert.Equal(t, "", cmd.Flags().Lookup("output").Value.String()) + assert.Empty(t, cmd.Flags().Lookup("output").Value.String()) } func cmdWithFormat(use string, format string) *cobra.Command { diff --git a/pkg/install/resources_test.go b/pkg/install/resources_test.go index cb37b1e3f..6118c04bb 100644 --- a/pkg/install/resources_test.go +++ b/pkg/install/resources_test.go @@ -54,13 +54,13 @@ func TestResources(t *testing.T) { crb := ClusterRoleBinding(DefaultVeleroNamespace) // The CRB is a cluster-scoped resource - assert.Equal(t, "", crb.ObjectMeta.Namespace) + assert.Empty(t, crb.ObjectMeta.Namespace) assert.Equal(t, "velero", crb.ObjectMeta.Name) assert.Equal(t, "velero", crb.Subjects[0].Namespace) customNamespaceCRB := ClusterRoleBinding("foo") // The CRB is a cluster-scoped resource - assert.Equal(t, "", customNamespaceCRB.ObjectMeta.Namespace) + assert.Empty(t, customNamespaceCRB.ObjectMeta.Namespace) assert.Equal(t, "velero-foo", customNamespaceCRB.ObjectMeta.Name) assert.Equal(t, "foo", customNamespaceCRB.Subjects[0].Namespace) diff --git a/pkg/repository/maintenance/maintenance_test.go b/pkg/repository/maintenance/maintenance_test.go index 2a41d21f3..079433f60 100644 --- a/pkg/repository/maintenance/maintenance_test.go +++ b/pkg/repository/maintenance/maintenance_test.go @@ -289,14 +289,14 @@ func TestGetResultFromJob(t *testing.T) { // test an error should be returned result, err := getResultFromJob(cli, job) assert.EqualError(t, err, "no pod found for job test-job") - assert.Equal(t, "", result) + assert.Empty(t, result) cli = fake.NewClientBuilder().WithObjects(job, pod).Build() // test an error should be returned result, err = getResultFromJob(cli, job) assert.EqualError(t, err, "no container statuses found for job test-job") - assert.Equal(t, "", result) + assert.Empty(t, result) // Set a non-terminated container status to the pod pod.Status = corev1api.PodStatus{ @@ -311,7 +311,7 @@ func TestGetResultFromJob(t *testing.T) { cli = fake.NewClientBuilder().WithObjects(job, pod).Build() result, err = getResultFromJob(cli, job) assert.EqualError(t, err, "container for job test-job is not terminated") - assert.Equal(t, "", result) + assert.Empty(t, result) // Set a terminated container status to the pod pod.Status = corev1api.PodStatus{ @@ -328,7 +328,7 @@ func TestGetResultFromJob(t *testing.T) { cli = fake.NewClientBuilder().WithObjects(job, pod).Build() result, err = getResultFromJob(cli, job) assert.NoError(t, err) - assert.Equal(t, "", result) + assert.Empty(t, result) // Set a terminated container status with invalidate message to the pod pod.Status = corev1api.PodStatus{ @@ -346,7 +346,7 @@ func TestGetResultFromJob(t *testing.T) { cli = fake.NewClientBuilder().WithObjects(job, pod).Build() result, err = getResultFromJob(cli, job) assert.EqualError(t, err, "error to locate repo maintenance error indicator from termination message") - assert.Equal(t, "", result) + assert.Empty(t, result) // Set a terminated container status with empty maintenance error to the pod pod.Status = corev1api.PodStatus{ @@ -364,7 +364,7 @@ func TestGetResultFromJob(t *testing.T) { cli = fake.NewClientBuilder().WithObjects(job, pod).Build() result, err = getResultFromJob(cli, job) assert.EqualError(t, err, "nothing after repo maintenance error indicator in termination message") - assert.Equal(t, "", result) + assert.Empty(t, result) // Set a terminated container status with maintenance error to the pod pod.Status = corev1api.PodStatus{ diff --git a/pkg/repository/udmrepo/kopialib/lib_repo_test.go b/pkg/repository/udmrepo/kopialib/lib_repo_test.go index 1de0d590f..1e9da9a92 100644 --- a/pkg/repository/udmrepo/kopialib/lib_repo_test.go +++ b/pkg/repository/udmrepo/kopialib/lib_repo_test.go @@ -938,7 +938,7 @@ func TestUpdateProgress(t *testing.T) { if len(tc.logMessage) > 0 { assert.Contains(t, logMessage, tc.logMessage) } else { - assert.Equal(t, "", logMessage) + assert.Empty(t, logMessage) } }) } @@ -1340,7 +1340,7 @@ func TestMaintainProgress(t *testing.T) { if len(tc.logMessage) > 0 { assert.Contains(t, logMessage, tc.logMessage) } else { - assert.Equal(t, "", logMessage) + assert.Empty(t, logMessage) } }) } diff --git a/pkg/restic/command_test.go b/pkg/restic/command_test.go index dc8ff0f29..6048478d7 100644 --- a/pkg/restic/command_test.go +++ b/pkg/restic/command_test.go @@ -26,7 +26,7 @@ import ( func TestRepoName(t *testing.T) { c := &Command{RepoIdentifier: ""} - assert.Equal(t, "", c.RepoName()) + assert.Empty(t, c.RepoName()) c.RepoIdentifier = "s3:s3.amazonaws.com/bucket/prefix/repo" assert.Equal(t, "repo", c.RepoName())