File tree 1 file changed +51
-0
lines changed
1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -53,3 +53,54 @@ func TestSetAllCallbackAccept(t *testing.T) {
53
53
})
54
54
}
55
55
}
56
+
57
+ func TestGetExtFromSchema (t * testing.T ) {
58
+ tests := []struct {
59
+ name string
60
+ schema * spec.Schema
61
+ expectedExtension * extension
62
+ expectedError bool
63
+ }{
64
+ {
65
+ name : "Extension Present" ,
66
+ schema : & spec.Schema {
67
+ VendorExtensible : spec.VendorExtensible {
68
+ Extensions : map [string ]interface {}{
69
+ K8sCliExtensionKey : & extension {
70
+ Setter : & setter {
71
+ Name : "testSetter" ,
72
+ Value : "testValue" ,
73
+ },
74
+ },
75
+ },
76
+ },
77
+ },
78
+ expectedExtension : & extension {
79
+ Setter : & setter {
80
+ Name : "testSetter" ,
81
+ Value : "testValue" ,
82
+ },
83
+ },
84
+ expectedError : false ,
85
+ },
86
+ {
87
+ name : "Extension Not Present" ,
88
+ schema : & spec.Schema {},
89
+ expectedError : false ,
90
+ },
91
+ }
92
+
93
+ for _ , test := range tests {
94
+ t .Run (test .name , func (t * testing.T ) {
95
+ g := NewWithT (t )
96
+ ext , err := getExtFromSchema (test .schema )
97
+
98
+ if test .expectedError {
99
+ g .Expect (err ).To (HaveOccurred ())
100
+ } else {
101
+ g .Expect (err ).ToNot (HaveOccurred ())
102
+ g .Expect (ext ).To (Equal (test .expectedExtension ))
103
+ }
104
+ })
105
+ }
106
+ }
You can’t perform that action at this time.
0 commit comments