From 9e7737d7d4c09f90bab7abf8e646f21f1d4eec6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arda=20G=C3=BC=C3=A7l=C3=BC?= Date: Tue, 7 Mar 2023 08:45:26 +0300 Subject: [PATCH] Unit tests to assure List type not support fieldvalidation --- .../pkg/resource/query_param_verifier.go | 1 + .../pkg/resource/query_param_verifier_test.go | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/staging/src/k8s.io/cli-runtime/pkg/resource/query_param_verifier.go b/staging/src/k8s.io/cli-runtime/pkg/resource/query_param_verifier.go index d933b89d8b1..3b08025c3ef 100644 --- a/staging/src/k8s.io/cli-runtime/pkg/resource/query_param_verifier.go +++ b/staging/src/k8s.io/cli-runtime/pkg/resource/query_param_verifier.go @@ -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" diff --git a/staging/src/k8s.io/cli-runtime/pkg/resource/query_param_verifier_test.go b/staging/src/k8s.io/cli-runtime/pkg/resource/query_param_verifier_test.go index 8b67e1094b3..b1c1bb620ba 100644 --- a/staging/src/k8s.io/cli-runtime/pkg/resource/query_param_verifier_test.go +++ b/staging/src/k8s.io/cli-runtime/pkg/resource/query_param_verifier_test.go @@ -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") + } }