apiextensions: add invalid validation schema regex test

This commit is contained in:
Dr. Stefan Schimanski 2019-05-28 22:52:48 +02:00
parent 6d70e7ff01
commit ba5c9b492e

View File

@ -139,7 +139,7 @@ func convertNullTypeToNullable(x interface{}) interface{} {
}
}
func TestNullable(t *testing.T) {
func TestValidateCustomResource(t *testing.T) {
type args struct {
schema apiextensions.JSONSchemaProps
object interface{}
@ -149,6 +149,7 @@ func TestNullable(t *testing.T) {
args args
wantErr bool
}{
// TODO: make more complete
{"!nullable against non-null", args{
apiextensions.JSONSchemaProps{
Properties: map[string]apiextensions.JSONSchemaProps{
@ -235,6 +236,17 @@ func TestNullable(t *testing.T) {
},
map[string]interface{}{"field": nil},
}, 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 {
t.Run(tt.name, func(t *testing.T) {