fix len rule from testifylint

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
Matthieu MOREL
2025-06-22 22:41:08 +02:00
parent 9500f0b82f
commit 59825a0506
9 changed files with 11 additions and 12 deletions
-1
View File
@@ -264,7 +264,6 @@ linters:
- equal-values # FIXME
- float-compare
- go-require
- len # FIXME
- require-error
enable-all: true
@@ -103,7 +103,7 @@ func RunRestartableDelegateTests(
// This Function asserts that the actual outputs match the expected outputs
checkOutputs := func(expected []any, actual []reflect.Value) {
require.Equal(t, len(expected), len(actual))
require.Len(t, actual, len(expected))
for i := range actual {
// Get the underlying value from the reflect.Value
+1 -1
View File
@@ -90,7 +90,7 @@ func TestSetOfOrLabelSelector(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
require.NoError(t, selector.Set(test.inputStr))
assert.Equal(t, len(test.expectedSelector.OrLabelSelectors), len(selector.OrLabelSelectors))
assert.Len(t, selector.OrLabelSelectors, len(test.expectedSelector.OrLabelSelectors))
assert.Equal(t, test.expectedSelector.String(), selector.String())
})
}
+1 -1
View File
@@ -78,7 +78,7 @@ func TestSortBackups(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
sortBackupsByPrefixAndTimestamp(test.backupList)
if assert.Equal(t, len(test.backupList.Items), len(test.expected)) {
if assert.Len(t, test.backupList.Items, len(test.expected)) {
for i := range test.expected {
assert.Equal(t, test.expected[i].Name, test.backupList.Items[i].Name)
}
@@ -1070,7 +1070,7 @@ func TestDeleteMovedSnapshots(t *testing.T) {
if test.expected == nil {
assert.Nil(t, errs)
} else {
assert.Equal(t, len(test.expected), len(errs))
assert.Len(t, errs, len(test.expected))
for i := range test.expected {
assert.EqualError(t, errs[i], test.expected[i])
}
+1 -1
View File
@@ -1083,7 +1083,7 @@ func TestBatchForget(t *testing.T) {
if tc.expectedErr == nil {
assert.Empty(t, errs)
} else {
assert.Equal(t, len(tc.expectedErr), len(errs))
assert.Len(t, errs, len(tc.expectedErr))
for i := range tc.expectedErr {
assert.EqualError(t, errs[i], tc.expectedErr[i])
+3 -3
View File
@@ -1028,15 +1028,15 @@ func TestInvalidTarballContents(t *testing.T) {
func assertWantErrsOrWarnings(t *testing.T, wantRes Result, res Result) {
t.Helper()
if wantRes.Velero != nil {
assert.Equal(t, len(wantRes.Velero), len(res.Velero))
assert.Len(t, res.Velero, len(wantRes.Velero))
for i := range res.Velero {
assert.Contains(t, res.Velero[i], wantRes.Velero[i])
}
}
if wantRes.Namespaces != nil {
assert.Equal(t, len(wantRes.Namespaces), len(res.Namespaces))
assert.Len(t, res.Namespaces, len(wantRes.Namespaces))
for ns := range res.Namespaces {
assert.Equal(t, len(wantRes.Namespaces[ns]), len(res.Namespaces[ns]))
assert.Len(t, res.Namespaces[ns], len(wantRes.Namespaces[ns]))
for i := range res.Namespaces[ns] {
assert.Contains(t, res.Namespaces[ns][i], wantRes.Namespaces[ns][i])
}
@@ -160,7 +160,7 @@ func TestValidateIncludesExcludes(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
errs := ValidateIncludesExcludes(tc.includes, tc.excludes)
require.Equal(t, len(tc.want), len(errs))
require.Len(t, errs, len(tc.want))
for i := 0; i < len(tc.want); i++ {
assert.Equal(t, tc.want[i].Error(), errs[i].Error())
@@ -361,7 +361,7 @@ func TestValidateScopedIncludesExcludes(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
errs := ValidateScopedIncludesExcludes(tc.includes, tc.excludes)
require.Equal(t, len(tc.wantErr), len(errs))
require.Len(t, errs, len(tc.wantErr))
for i := 0; i < len(tc.wantErr); i++ {
assert.Equal(t, tc.wantErr[i].Error(), errs[i].Error())
+1 -1
View File
@@ -85,7 +85,7 @@ func TestFire(t *testing.T) {
err := hook.Fire(entry)
require.Equal(t, test.expectedErr, err != nil)
require.Equal(t, len(test.expectedEntryFields), len(entry.Data))
require.Len(t, entry.Data, len(test.expectedEntryFields))
for key, expectedValue := range test.expectedEntryFields {
actualValue, found := entry.Data[key]