...
1
16
17 package polymorphichelpers
18
19 import (
20 "testing"
21
22 appsv1 "k8s.io/api/apps/v1"
23 corev1 "k8s.io/api/core/v1"
24 extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
25 "k8s.io/apimachinery/pkg/runtime/schema"
26 )
27
28 func TestCanBeExposed(t *testing.T) {
29 tests := []struct {
30 kind schema.GroupKind
31 expectErr bool
32 }{
33 {
34 kind: corev1.SchemeGroupVersion.WithKind("ReplicationController").GroupKind(),
35 expectErr: false,
36 },
37 {
38 kind: corev1.SchemeGroupVersion.WithKind("Service").GroupKind(),
39 expectErr: false,
40 },
41 {
42 kind: corev1.SchemeGroupVersion.WithKind("Pod").GroupKind(),
43 expectErr: false,
44 },
45 {
46 kind: appsv1.SchemeGroupVersion.WithKind("Deployment").GroupKind(),
47 expectErr: false,
48 },
49 {
50 kind: extensionsv1beta1.SchemeGroupVersion.WithKind("ReplicaSet").GroupKind(),
51 expectErr: false,
52 },
53 {
54 kind: corev1.SchemeGroupVersion.WithKind("Node").GroupKind(),
55 expectErr: true,
56 },
57 }
58
59 for _, test := range tests {
60 err := canBeExposed(test.kind)
61 if test.expectErr && err == nil {
62 t.Error("unexpected non-error")
63 }
64 if !test.expectErr && err != nil {
65 t.Errorf("unexpected error: %v", err)
66 }
67 }
68 }
69
View as plain text