e2e: replace gomega.HaveLen(0) with gomega.BeEmpty()

The failure message becomes nicer. Found with the new ginkgolinter, for
example:

    test/e2e/apps/cronjob.go:113:3: ginkgo-linter: wrong length assertion; consider using `gomega.Expect(jobs.Items).To(gomega.BeEmpty())` instead (ginkgolinter)
     		gomega.Expect(jobs.Items).To(gomega.HaveLen(0))
     		^
This commit is contained in:
Patrick Ohly 2023-06-27 13:50:00 +02:00
parent e7df337eba
commit f618e61332
2 changed files with 2 additions and 2 deletions

View File

@ -110,7 +110,7 @@ var _ = SIGDescribe("CronJob", func() {
ginkgo.By("Ensuring no job exists by listing jobs explicitly")
jobs, err := f.ClientSet.BatchV1().Jobs(f.Namespace.Name).List(ctx, metav1.ListOptions{})
framework.ExpectNoError(err, "Failed to list the CronJobs in namespace %s", f.Namespace.Name)
gomega.Expect(jobs.Items).To(gomega.HaveLen(0))
gomega.Expect(jobs.Items).To(gomega.BeEmpty())
ginkgo.By("Removing cronjob")
err = deleteCronJob(ctx, f.ClientSet, f.Namespace.Name, cronJob.Name)

View File

@ -695,7 +695,7 @@ func stopDeployment(ctx context.Context, c clientset.Interface, ns, deploymentNa
options := metav1.ListOptions{LabelSelector: selector.String()}
rss, err := c.AppsV1().ReplicaSets(ns).List(ctx, options)
framework.ExpectNoError(err)
gomega.Expect(rss.Items).Should(gomega.HaveLen(0))
gomega.Expect(rss.Items).Should(gomega.BeEmpty())
framework.Logf("Ensuring deployment %s's Pods were deleted", deploymentName)
var pods *v1.PodList
if err := wait.PollImmediate(time.Second, timeout, func() (bool, error) {