Unit tests to assure List type not support fieldvalidation

This commit is contained in:
Arda Güçlü 2023-03-07 08:45:26 +03:00
parent e78d05daec
commit 9e7737d7d4
2 changed files with 21 additions and 0 deletions

View File

@ -19,6 +19,7 @@ package resource
import (
"errors"
"fmt"
openapi_v2 "github.com/google/gnostic/openapiv2"
yaml "gopkg.in/yaml.v2"
"k8s.io/apimachinery/pkg/runtime/schema"

View File

@ -69,6 +69,16 @@ func TestSupportsQueryParam(t *testing.T) {
supports: false,
queryParam: QueryParamFieldValidation,
},
{
gvk: schema.GroupVersionKind{
Group: "",
Version: "v1",
Kind: "List",
},
success: false,
supports: false,
queryParam: QueryParamFieldValidation,
},
}
for _, test := range tests {
@ -124,6 +134,11 @@ func TestFieldValidationVerifier(t *testing.T) {
if err == nil {
t.Fatalf("Random doesn't support fieldValidation, yet no error found")
}
err = fieldValidationVerifier.HasSupport(schema.GroupVersionKind{Group: "", Version: "v1", Kind: "List"})
if err == nil {
t.Fatalf("List does not support fieldValidation, yet no error found")
}
}
type EmptyOpenAPI struct{}
@ -159,4 +174,9 @@ func TestFieldValidationVerifierNoOpenAPI(t *testing.T) {
if err == nil {
t.Fatalf("MyCRD doesn't support fieldValidation, yet no error found")
}
err = fieldValidationVerifier.HasSupport(schema.GroupVersionKind{Group: "", Version: "v1", Kind: "List"})
if err == nil {
t.Fatalf("List does not support fieldValidation, yet no error found")
}
}