lint(ginkgolinter): expect (not)to HaveOccurred (#7565)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
Matthieu MOREL
2024-03-29 15:05:48 +01:00
committed by GitHub
parent 67bd694d1b
commit 3d6dab0708
18 changed files with 50 additions and 53 deletions

View File

@@ -100,12 +100,12 @@ var _ = Describe("Backup Storage Location Reconciler", func() {
NamespacedName: types.NamespacedName{Namespace: location.Namespace, Name: location.Name},
})
Expect(actualResult).To(BeEquivalentTo(ctrl.Result{}))
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
key := client.ObjectKey{Name: location.Name, Namespace: location.Namespace}
instance := &velerov1api.BackupStorageLocation{}
err = r.client.Get(ctx, key, instance)
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(instance.Spec.Default).To(BeIdenticalTo(tests[i].expectedIsDefault))
Expect(instance.Status.Phase).To(BeIdenticalTo(tests[i].expectedPhase))
}
@@ -165,12 +165,12 @@ var _ = Describe("Backup Storage Location Reconciler", func() {
NamespacedName: types.NamespacedName{Namespace: location.Namespace, Name: location.Name},
})
Expect(actualResult).To(BeEquivalentTo(ctrl.Result{}))
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
key := client.ObjectKey{Name: location.Name, Namespace: location.Namespace}
instance := &velerov1api.BackupStorageLocation{}
err = r.client.Get(ctx, key, instance)
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(instance.Spec.Default).To(BeIdenticalTo(tests[i].expectedIsDefault))
}
})

View File

@@ -451,7 +451,7 @@ var _ = Describe("Backup Sync Reconciler", func() {
})
Expect(actualResult).To(BeEquivalentTo(ctrl.Result{}))
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
// process the cloud backups
for _, cloudBackupData := range test.cloudBackups {
@@ -467,7 +467,7 @@ var _ = Describe("Backup Sync Reconciler", func() {
cloudBackupData.backup.Status.Expiration.After(fakeClock.Now())) {
Expect(apierrors.IsNotFound(err)).To(BeTrue())
} else {
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
// did this cloud backup already exist in the cluster?
var existing *velerov1api.Backup
@@ -496,7 +496,7 @@ var _ = Describe("Backup Sync Reconciler", func() {
locationName = label.GetValidName(locationName)
}
Expect(locationName).To(BeEquivalentTo(obj.Labels[velerov1api.StorageLocationLabel]))
Expect(len(obj.Labels[velerov1api.StorageLocationLabel]) <= validation.DNS1035LabelMaxLength).To(BeTrue())
Expect(len(obj.Labels[velerov1api.StorageLocationLabel])).To(BeNumerically("<=", validation.DNS1035LabelMaxLength))
}
}

View File

@@ -62,7 +62,7 @@ var _ = Describe("Download Request Reconciler", func() {
// now will be used to set the fake clock's time; capture
// it here so it can be referenced in the test case defs.
now, err := time.Parse(time.RFC1123, time.RFC1123)
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
now = now.Local()
rClock := testclocks.NewFakeClock(now)
@@ -86,22 +86,22 @@ var _ = Describe("Download Request Reconciler", func() {
fakeClient := fake.NewClientBuilder().WithScheme(scheme.Scheme).Build()
err = fakeClient.Create(context.TODO(), test.downloadRequest)
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
if test.backup != nil {
err := fakeClient.Create(context.TODO(), test.backup)
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
}
if test.backupLocation != nil {
err := fakeClient.Create(context.TODO(), test.backupLocation)
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
backupStores[test.backupLocation.Name] = &persistencemocks.BackupStore{}
}
if test.restore != nil {
err := fakeClient.Create(context.TODO(), test.restore)
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
}
// Setup reconciler
@@ -129,7 +129,7 @@ var _ = Describe("Download Request Reconciler", func() {
Expect(actualResult).To(BeEquivalentTo(test.expectedRequeue))
if test.expectedReconcileErr == "" {
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
} else {
Expect(err.Error()).To(Equal(test.expectedReconcileErr))
}
@@ -146,7 +146,7 @@ var _ = Describe("Download Request Reconciler", func() {
} else {
Expect(instance.Status).ToNot(Equal(test.downloadRequest.Status))
}
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
}
if test.expectGetsURL {

View File

@@ -141,7 +141,7 @@ var _ = Describe("PodVolumeBackup Reconciler", func() {
// `now` will be used to set the fake clock's time; capture
// it here so it can be referenced in the test case defs.
now, err := time.Parse(time.RFC1123, time.RFC1123)
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
now = now.Local()
DescribeTable("a pod volume backup",
@@ -150,21 +150,21 @@ var _ = Describe("PodVolumeBackup Reconciler", func() {
fakeClient := fake.NewClientBuilder().WithScheme(scheme.Scheme).Build()
err = fakeClient.Create(ctx, test.pvb)
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
err = fakeClient.Create(ctx, test.pod)
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
err = fakeClient.Create(ctx, test.bsl)
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
err = fakeClient.Create(ctx, test.backupRepo)
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
fakeFS := velerotest.NewFakeFileSystem()
pathGlob := fmt.Sprintf("/host_pods/%s/volumes/*/%s", "", "pvb-1-volume")
_, err = fakeFS.Create(pathGlob)
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
credentialFileStore, err := credentials.NewNamespacedFileStore(
fakeClient,
@@ -173,7 +173,7 @@ var _ = Describe("PodVolumeBackup Reconciler", func() {
fakeFS,
)
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
if test.dataMgr == nil {
test.dataMgr = datapath.NewManager(1)
@@ -208,7 +208,7 @@ var _ = Describe("PodVolumeBackup Reconciler", func() {
})
Expect(actualResult).To(BeEquivalentTo(test.expectedRequeue))
if test.expectedErrMsg == "" {
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
} else {
Expect(err.Error()).To(BeEquivalentTo(test.expectedErrMsg))
}
@@ -222,7 +222,7 @@ var _ = Describe("PodVolumeBackup Reconciler", func() {
if test.expected == nil {
Expect(apierrors.IsNotFound(err)).To(BeTrue())
} else {
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
Eventually(pvb.Status.Phase).Should(Equal(test.expected.Status.Phase))
}

View File

@@ -55,7 +55,7 @@ var _ = Describe("Server Status Request Reconciler", func() {
// `now` will be used to set the fake clock's time; capture
// it here so it can be referenced in the test case defs.
now, err := time.Parse(time.RFC1123, time.RFC1123)
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
now = now.Local()
DescribeTable("a Server Status request",
@@ -79,7 +79,7 @@ var _ = Describe("Server Status Request Reconciler", func() {
Expect(actualResult).To(BeEquivalentTo(test.expectedRequeue))
if test.expectedErrMsg == "" {
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
} else {
Expect(err.Error()).To(BeEquivalentTo(test.expectedErrMsg))
return
@@ -92,7 +92,7 @@ var _ = Describe("Server Status Request Reconciler", func() {
if test.expected == nil {
Expect(apierrors.IsNotFound(err)).To(BeTrue())
} else {
Expect(err).To(BeNil())
Expect(err).ToNot(HaveOccurred())
Eventually(instance.Status.Phase == test.expected.Status.Phase, timeout).Should(BeTrue())
}
},