fix require-error rule from testifylint

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
Matthieu MOREL
2025-06-01 21:44:09 +02:00
parent 3024e6223e
commit 07ea14962c
99 changed files with 483 additions and 440 deletions

View File

@@ -48,14 +48,14 @@ func TestBackupPVAction(t *testing.T) {
// no spec.volumeName should result in no error
// and no additional items
_, additional, err := a.Execute(pvc, backup)
assert.NoError(t, err)
require.NoError(t, err)
assert.Empty(t, additional)
// empty spec.volumeName should result in no error
// and no additional items
pvc.Object["spec"].(map[string]any)["volumeName"] = ""
_, additional, err = a.Execute(pvc, backup)
assert.NoError(t, err)
require.NoError(t, err)
assert.Empty(t, additional)
// Action should clean the spec.Selector when the StorageClassName is not set.
@@ -146,6 +146,6 @@ func TestBackupPVAction(t *testing.T) {
// result in no error and no additional items
pvc.Object["spec"].(map[string]any)["volumeName"] = ""
_, additional, err = a.Execute(pvc, backup)
assert.NoError(t, err)
require.NoError(t, err)
assert.Empty(t, additional)
}

View File

@@ -385,7 +385,7 @@ func TestServiceAccountActionExecute(t *testing.T) {
res, additional, err := action.Execute(test.serviceAccount, nil)
assert.Equal(t, test.serviceAccount, res)
assert.NoError(t, err)
require.NoError(t, err)
// ensure slices are ordered for valid comparison
sort.Slice(test.expectedAdditionalItems, func(i, j int) bool {
@@ -592,7 +592,7 @@ func TestServiceAccountActionExecuteOnBeta1(t *testing.T) {
res, additional, err := action.Execute(test.serviceAccount, nil)
assert.Equal(t, test.serviceAccount, res)
assert.NoError(t, err)
require.NoError(t, err)
// ensure slices are ordered for valid comparison
sort.Slice(test.expectedAdditionalItems, func(i, j int) bool {

View File

@@ -1476,7 +1476,7 @@ func TestBackupItemActionsForSkippedPV(t *testing.T) {
}
err := h.backupper.Backup(h.log, tc.backupReq, backupFile, actions, nil, nil)
assert.NoError(t, err)
require.NoError(t, err)
if tc.expectSkippedPVs != nil {
for pvName, reasons := range tc.expectSkippedPVs {
@@ -1694,7 +1694,7 @@ func TestBackupActionsRunForCorrectItems(t *testing.T) {
}
err := h.backupper.Backup(h.log, req, backupFile, actions, nil, nil)
assert.NoError(t, err)
require.NoError(t, err)
for action, want := range tc.actions {
assert.Equal(t, want, action.ids)
@@ -1928,7 +1928,7 @@ func TestBackupActionModifications(t *testing.T) {
}
err := h.backupper.Backup(h.log, req, backupFile, tc.actions, nil, nil)
assert.NoError(t, err)
require.NoError(t, err)
assertTarballFileContents(t, backupFile, tc.want)
})
@@ -2188,7 +2188,7 @@ func TestBackupActionAdditionalItems(t *testing.T) {
}
err := h.backupper.Backup(h.log, req, backupFile, tc.actions, nil, nil)
assert.NoError(t, err)
require.NoError(t, err)
assertTarballContents(t, backupFile, append(tc.want, "metadata/version")...)
})
@@ -2454,7 +2454,7 @@ func TestItemBlockActionsRunForCorrectItems(t *testing.T) {
}
err := h.backupper.Backup(h.log, req, backupFile, nil, actions, nil)
assert.NoError(t, err)
require.NoError(t, err)
for action, want := range tc.actions {
assert.Equal(t, want, action.ids)
@@ -2790,7 +2790,7 @@ func TestItemBlockActionRelatedItems(t *testing.T) {
}
err := h.backupper.Backup(h.log, req, backupFile, nil, tc.actions, nil)
assert.NoError(t, err)
require.NoError(t, err)
assertTarballContents(t, backupFile, append(tc.want, "metadata/version")...)
})
@@ -3267,7 +3267,7 @@ func TestBackupWithSnapshots(t *testing.T) {
}
err := h.backupper.Backup(h.log, tc.req, backupFile, nil, nil, tc.snapshotterGetter)
assert.NoError(t, err)
require.NoError(t, err)
assert.Equal(t, tc.want, tc.req.VolumeSnapshots)
})
@@ -3434,7 +3434,7 @@ func TestBackupWithAsyncOperations(t *testing.T) {
}
err := h.backupper.Backup(h.log, tc.req, backupFile, tc.actions, nil, nil)
assert.NoError(t, err)
require.NoError(t, err)
resultOper := *tc.req.GetItemOperationsList()
// set want Created times so it won't fail the assert.Equal test
@@ -4423,7 +4423,7 @@ func assertTarballFileContents(t *testing.T, backupFile io.Reader, want map[stri
// json-unmarshal the data from the tarball
var got unstructuredObject
err := json.Unmarshal(gotData, &got)
assert.NoError(t, err)
require.NoError(t, err)
if err != nil {
continue
}