mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-07 04:03:20 +00:00
test: fix ginkgolinter issues
All of these issues were reported by https://github.com/nunnatsa/ginkgolinter. Fixing these issues is useful (several expressions get simpler, using framework.ExpectNoError is better because it has additional support for failures) and a necessary step for enabling that linter in our golangci-lint invocation.
This commit is contained in:
@@ -208,7 +208,7 @@ var _ = SIGDescribe("CronJob", func() {
|
||||
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)
|
||||
activeJobs, _ := filterActiveJobs(jobs)
|
||||
gomega.Expect(len(activeJobs)).To(gomega.BeNumerically(">=", 1))
|
||||
gomega.Expect(activeJobs).ToNot(gomega.BeEmpty())
|
||||
|
||||
ginkgo.By("Removing cronjob")
|
||||
err = deleteCronJob(ctx, f.ClientSet, f.Namespace.Name, cronJob.Name)
|
||||
@@ -459,8 +459,7 @@ var _ = SIGDescribe("CronJob", func() {
|
||||
// CronJob resource delete operations
|
||||
expectFinalizer := func(cj *batchv1.CronJob, msg string) {
|
||||
framework.ExpectNotEqual(cj.DeletionTimestamp, nil, fmt.Sprintf("expected deletionTimestamp, got nil on step: %q, cronjob: %+v", msg, cj))
|
||||
gomega.Expect(len(cj.Finalizers)).To(gomega.BeNumerically(">", 0), "expected finalizers on cronjob, got none on step: %q, cronjob: %+v", msg, cj)
|
||||
|
||||
gomega.Expect(cj.Finalizers).ToNot(gomega.BeEmpty(), "expected finalizers on cronjob, got none on step: %q, cronjob: %+v", msg, cj)
|
||||
}
|
||||
|
||||
ginkgo.By("deleting")
|
||||
|
@@ -1028,7 +1028,7 @@ func listDaemonPods(ctx context.Context, c clientset.Interface, ns string, label
|
||||
options := metav1.ListOptions{LabelSelector: selector.String()}
|
||||
podList, err := c.CoreV1().Pods(ns).List(ctx, options)
|
||||
framework.ExpectNoError(err)
|
||||
gomega.Expect(len(podList.Items)).To(gomega.BeNumerically(">", 0))
|
||||
gomega.Expect(podList.Items).ToNot(gomega.BeEmpty())
|
||||
return podList
|
||||
}
|
||||
|
||||
@@ -1191,7 +1191,7 @@ func checkDaemonSetPodsLabels(podList *v1.PodList, hash string) {
|
||||
continue
|
||||
}
|
||||
podHash := pod.Labels[appsv1.DefaultDaemonSetUniqueLabelKey]
|
||||
gomega.Expect(len(podHash)).To(gomega.BeNumerically(">", 0))
|
||||
gomega.Expect(podHash).ToNot(gomega.BeEmpty())
|
||||
if len(hash) > 0 {
|
||||
framework.ExpectEqual(podHash, hash, "unexpected hash for pod %s", pod.Name)
|
||||
}
|
||||
@@ -1221,7 +1221,7 @@ func listDaemonHistories(ctx context.Context, c clientset.Interface, ns string,
|
||||
options := metav1.ListOptions{LabelSelector: selector.String()}
|
||||
historyList, err := c.AppsV1().ControllerRevisions(ns).List(ctx, options)
|
||||
framework.ExpectNoError(err)
|
||||
gomega.Expect(len(historyList.Items)).To(gomega.BeNumerically(">", 0))
|
||||
gomega.Expect(historyList.Items).ToNot(gomega.BeEmpty())
|
||||
return historyList
|
||||
}
|
||||
|
||||
@@ -1231,7 +1231,7 @@ func curHistory(historyList *appsv1.ControllerRevisionList, ds *appsv1.DaemonSet
|
||||
for i := range historyList.Items {
|
||||
history := &historyList.Items[i]
|
||||
// Every history should have the hash label
|
||||
gomega.Expect(len(history.Labels[appsv1.DefaultDaemonSetUniqueLabelKey])).To(gomega.BeNumerically(">", 0))
|
||||
gomega.Expect(history.Labels[appsv1.DefaultDaemonSetUniqueLabelKey]).ToNot(gomega.BeEmpty())
|
||||
match, err := daemon.Match(ds, history)
|
||||
framework.ExpectNoError(err)
|
||||
if match {
|
||||
|
@@ -1338,7 +1338,7 @@ func listDeploymentReplicaSets(ctx context.Context, c clientset.Interface, ns st
|
||||
options := metav1.ListOptions{LabelSelector: selector.String()}
|
||||
rsList, err := c.AppsV1().ReplicaSets(ns).List(ctx, options)
|
||||
framework.ExpectNoError(err)
|
||||
gomega.Expect(len(rsList.Items)).To(gomega.BeNumerically(">", 0))
|
||||
gomega.Expect(rsList.Items).ToNot(gomega.BeEmpty())
|
||||
return rsList
|
||||
}
|
||||
|
||||
|
@@ -369,7 +369,7 @@ var _ = SIGDescribe("ReplicationController", func() {
|
||||
ginkgo.By("listing all ReplicationControllers")
|
||||
rcs, err := f.ClientSet.CoreV1().ReplicationControllers("").List(ctx, metav1.ListOptions{LabelSelector: "test-rc-static=true"})
|
||||
framework.ExpectNoError(err, "failed to list ReplicationController")
|
||||
gomega.Expect(len(rcs.Items)).To(gomega.BeNumerically(">", 0), "Expected to find a ReplicationController but none was found")
|
||||
gomega.Expect(rcs.Items).ToNot(gomega.BeEmpty(), "Expected to find a ReplicationController but none was found")
|
||||
|
||||
ginkgo.By("checking that ReplicationController has expected values")
|
||||
foundRc := false
|
||||
|
Reference in New Issue
Block a user