mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-13 11:34:54 +00:00
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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user