test: resolve remaining Ginkgo V2 and Gomega anti-patterns (#10440)

- Replaced Expect().Should() and Expect().ShouldNot() with .To() and .ToNot() across 12 files (Task 1).
- Replaced synchronously evaluated Eventually() with Expect() in server_status_request_controller_test.go (Task 2B).
- Extracted Skip() calls inside lazy callbacks into conditional checks using slices.Contains() in enable_api_group_extentions.go (Task 3).

Signed-off-by: opbot_xd <awasthikrishna23052005@gmail.com>
This commit is contained in:
opbot_xd
2026-09-01 06:43:04 +05:30
parent 3d50723567
commit a607892eb0
12 changed files with 41 additions and 44 deletions
@@ -19,6 +19,7 @@ package basic
import (
"context"
"fmt"
"slices"
"time"
. "github.com/onsi/ginkgo/v2"
@@ -45,26 +46,22 @@ func APIExtensionsVersionsTest() {
veleroCfg = VeleroCfg
Expect(KubectlConfigUseContext(context.Background(), veleroCfg.DefaultClusterContext)).To(Succeed())
srcVersions, err := GetAPIVersions(veleroCfg.DefaultClient, resourceName)
Expect(err).ShouldNot(HaveOccurred())
Expect(err).ToNot(HaveOccurred())
dstVersions, err := GetAPIVersions(veleroCfg.StandbyClient, resourceName)
Expect(err).ShouldNot(HaveOccurred())
Expect(err).ToNot(HaveOccurred())
Expect(srcVersions).Should(ContainElement("v1"), func() string {
if !slices.Contains(srcVersions, "v1") {
Skip("CRD with apiextension versions srcVersions should have v1")
return ""
})
Expect(srcVersions).Should(ContainElement("v1beta1"), func() string {
Skip("CRD with apiextension versions srcVersions should have v1")
return ""
})
Expect(dstVersions).Should(ContainElement("v1"), func() string {
}
if !slices.Contains(srcVersions, "v1beta1") {
Skip("CRD with apiextension versions srcVersions should have v1beta1")
}
if !slices.Contains(dstVersions, "v1") {
Skip("CRD with apiextension versions dstVersions should have v1")
return ""
})
Expect(len(srcVersions) > 1 && len(dstVersions) == 1).Should(BeTrue(), func() string {
}
if !(len(srcVersions) > 1 && len(dstVersions) == 1) {
Skip("Source cluster should support apiextension v1 and v1beta1, destination cluster should only support apiextension v1")
return ""
})
}
})
AfterEach(func() {
By(fmt.Sprintf("Switch to default kubeconfig context %s", veleroCfg.DefaultClusterContext), func() {