mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 15:58:37 +00:00
apiextensions: add invalid validation schema regex test
This commit is contained in:
parent
6d70e7ff01
commit
ba5c9b492e
@ -139,7 +139,7 @@ func convertNullTypeToNullable(x interface{}) interface{} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNullable(t *testing.T) {
|
func TestValidateCustomResource(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
schema apiextensions.JSONSchemaProps
|
schema apiextensions.JSONSchemaProps
|
||||||
object interface{}
|
object interface{}
|
||||||
@ -149,6 +149,7 @@ func TestNullable(t *testing.T) {
|
|||||||
args args
|
args args
|
||||||
wantErr bool
|
wantErr bool
|
||||||
}{
|
}{
|
||||||
|
// TODO: make more complete
|
||||||
{"!nullable against non-null", args{
|
{"!nullable against non-null", args{
|
||||||
apiextensions.JSONSchemaProps{
|
apiextensions.JSONSchemaProps{
|
||||||
Properties: map[string]apiextensions.JSONSchemaProps{
|
Properties: map[string]apiextensions.JSONSchemaProps{
|
||||||
@ -235,6 +236,17 @@ func TestNullable(t *testing.T) {
|
|||||||
},
|
},
|
||||||
map[string]interface{}{"field": nil},
|
map[string]interface{}{"field": nil},
|
||||||
}, false},
|
}, false},
|
||||||
|
{"invalid regex", args{
|
||||||
|
apiextensions.JSONSchemaProps{
|
||||||
|
Properties: map[string]apiextensions.JSONSchemaProps{
|
||||||
|
"field": {
|
||||||
|
Type: "string",
|
||||||
|
Pattern: "+",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
map[string]interface{}{"field": "foo"},
|
||||||
|
}, true},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user