Validate that PreferredVersion contains a valid option

This commit is contained in:
Stephen Heywood 2020-07-07 03:38:47 +00:00
parent e81b6dce15
commit f886164491
2 changed files with 14 additions and 7 deletions

View File

@ -9,7 +9,7 @@ go_library(
name = "go_default_library",
srcs = [
"aggregator.go",
"apigroup_list.go",
"apigroup_preferred_version.go",
"certs.go",
"chunking.go",
"crd_conversion_webhook.go",

View File

@ -28,9 +28,6 @@ var _ = SIGDescribe("apigroup list", func() {
f := framework.NewDefaultFramework("apigroup-list")
ginkgo.It("should locate PreferredVersion for each APIGroup", func() {
// TEST BEGINS HERE
ginkgo.By("[status] begin")
// get list of APIGroup endpoints
list := &metav1.APIGroupList{}
err := f.ClientSet.Discovery().RESTClient().Get().AbsPath("/apis/").Do(context.TODO()).Into(list)
@ -44,11 +41,21 @@ var _ = SIGDescribe("apigroup list", func() {
checkGroup := &metav1.APIGroup{}
apiPath := "/apis/" + group.Name + "/"
err = f.ClientSet.Discovery().RESTClient().Get().AbsPath(apiPath).Do(context.TODO()).Into(checkGroup)
framework.ExpectNoError(err, "Fail to access: %s", apiPath)
// get PreferredVersion for endpoint
framework.Logf("PreferredVersion: %v", checkGroup.PreferredVersion)
framework.Logf("PreferredVersion.GroupVersion: %s", checkGroup.PreferredVersion.GroupVersion)
framework.Logf("Versions found %v", checkGroup.Versions)
// confirm that the PreferredVersion is a valid version
match := false
for _, version := range checkGroup.Versions {
if version.GroupVersion == checkGroup.PreferredVersion.GroupVersion {
framework.Logf("%s matches %s", version.GroupVersion, checkGroup.PreferredVersion.GroupVersion)
match = true
break
}
}
framework.ExpectEqual(true, match, "failed to find a valid version for PreferredVersion")
}
})
})