mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-20 23:14:17 +00:00
linter(testifylint): use Len or Empty for arrays testing (#7555)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
@@ -50,14 +50,14 @@ func TestBackupPVAction(t *testing.T) {
|
||||
// and no additional items
|
||||
_, additional, err := a.Execute(pvc, backup)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, additional, 0)
|
||||
assert.Empty(t, additional)
|
||||
|
||||
// empty spec.volumeName should result in no error
|
||||
// and no additional items
|
||||
pvc.Object["spec"].(map[string]interface{})["volumeName"] = ""
|
||||
_, additional, err = a.Execute(pvc, backup)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, additional, 0)
|
||||
assert.Empty(t, additional)
|
||||
|
||||
// Action should clean the spec.Selector when the StorageClassName is not set.
|
||||
input := builder.ForPersistentVolumeClaim("abc", "abc").VolumeName("pv").Selector(&metav1.LabelSelector{MatchLabels: map[string]string{"abc": "abc"}}).Phase(corev1.ClaimBound).Result()
|
||||
@@ -119,21 +119,21 @@ func TestBackupPVAction(t *testing.T) {
|
||||
pvc.Object["spec"].(map[string]interface{})["volumeName"] = "myVolume"
|
||||
_, additional, err = a.Execute(pvc, backup)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, additional, 0)
|
||||
require.Empty(t, additional)
|
||||
|
||||
// non-empty spec.volumeName when status.phase is 'Pending'
|
||||
// should result in no error and no additional items
|
||||
pvc.Object["status"].(map[string]interface{})["phase"] = corev1api.ClaimPending
|
||||
_, additional, err = a.Execute(pvc, backup)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, additional, 0)
|
||||
require.Empty(t, additional)
|
||||
|
||||
// non-empty spec.volumeName when status.phase is 'Lost'
|
||||
// should result in no error and no additional items
|
||||
pvc.Object["status"].(map[string]interface{})["phase"] = corev1api.ClaimLost
|
||||
_, additional, err = a.Execute(pvc, backup)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, additional, 0)
|
||||
require.Empty(t, additional)
|
||||
|
||||
// non-empty spec.volumeName when status.phase is 'Bound'
|
||||
// should result in no error and one additional item for the PV
|
||||
@@ -148,5 +148,5 @@ func TestBackupPVAction(t *testing.T) {
|
||||
pvc.Object["spec"].(map[string]interface{})["volumeName"] = ""
|
||||
_, additional, err = a.Execute(pvc, backup)
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, additional, 0)
|
||||
assert.Empty(t, additional)
|
||||
}
|
||||
|
||||
@@ -60,5 +60,5 @@ func TestTrackUntrack(t *testing.T) {
|
||||
tracker.Track("pv3", podVolumeApproach, "it's set to opt-out")
|
||||
tracker.Untrack("pv3")
|
||||
tracker.Track("pv3", csiSnapshotApproach, "not applicable for CSI ")
|
||||
assert.Equal(t, 0, len(tracker.Summary()))
|
||||
assert.Empty(t, tracker.Summary())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user