...
1
16
17 package util
18
19 import (
20 "reflect"
21 "testing"
22 )
23
24 func TestCanonicalName(t *testing.T) {
25
26 var tests = []struct {
27 input string
28 expected string
29 }{
30 {"k8s.io/api/core/v1.Pod", "io.k8s.api.core.v1.Pod"},
31 {"k8s.io/api/networking/v1/NetworkPolicy", "io.k8s.api.networking.v1.NetworkPolicy"},
32 {"k8s.io/api/apps/v1beta2.Scale", "io.k8s.api.apps.v1beta2.Scale"},
33 {"servicecatalog.k8s.io/foo/bar/v1alpha1.Baz", "io.k8s.servicecatalog.foo.bar.v1alpha1.Baz"},
34 }
35 for _, test := range tests {
36 if got := ToRESTFriendlyName(test.input); got != test.expected {
37 t.Errorf("ToRESTFriendlyName(%q) = %v", test.input, got)
38 }
39 }
40 }
41
42 type TestType struct{}
43
44 func TestGetCanonicalTypeName(t *testing.T) {
45
46 var tests = []struct {
47 input interface{}
48 expected string
49 }{
50 {TestType{}, "k8s.io/kube-openapi/pkg/util.TestType"},
51 {&TestType{}, "k8s.io/kube-openapi/pkg/util.TestType"},
52 }
53 for _, test := range tests {
54 if got := GetCanonicalTypeName(test.input); got != test.expected {
55 t.Errorf("GetCanonicalTypeName(%q) = %v", reflect.TypeOf(test.input), got)
56 }
57 }
58 }
59
View as plain text