...
1 package validate
2
3 import (
4 "reflect"
5 "testing"
6
7 "github.com/stretchr/testify/assert"
8 "k8s.io/kube-openapi/pkg/validation/spec"
9 "k8s.io/kube-openapi/pkg/validation/strfmt"
10 )
11
12
13 func TestFormatValidator_EdgeCases(t *testing.T) {
14
15 v := formatValidator{
16 KnownFormats: strfmt.Default,
17 }
18
19
20
21 s := spec.Schema{}
22 s.Typed(stringType, "uuid")
23
24 sources := []interface{}{&s}
25
26 for _, source := range sources {
27
28 assert.True(t, v.Applies(source, reflect.String))
29
30 assert.False(t, v.Applies(source, reflect.Int))
31 }
32
33 assert.False(t, v.Applies("A string", reflect.String))
34 assert.False(t, v.Applies(nil, reflect.String))
35 }
36
View as plain text