@@ -116,26 +116,33 @@ func TestGetPluginInfo(t *testing.T) {
116116
117117func TestGetPluginCapabilities (t * testing.T ) {
118118 testCases := []struct {
119- name string
120- topologyInUse bool
121- expectedTypes []csi.PluginCapability_Service_Type
119+ name string
120+ topologyInUse bool
121+ expectedServiceTypes []csi.PluginCapability_Service_Type
122+ expectedExpansionTypes []csi.PluginCapability_VolumeExpansion_Type
122123 }{
123124 {
124125 name : "No Topology" ,
125126 topologyInUse : false ,
126- expectedTypes : []csi.PluginCapability_Service_Type {
127+ expectedServiceTypes : []csi.PluginCapability_Service_Type {
127128 csi .PluginCapability_Service_CONTROLLER_SERVICE ,
128129 csi .PluginCapability_Service_GROUP_CONTROLLER_SERVICE ,
129130 },
131+ expectedExpansionTypes : []csi.PluginCapability_VolumeExpansion_Type {
132+ csi .PluginCapability_VolumeExpansion_ONLINE ,
133+ },
130134 },
131135 {
132136 name : "With Topology" ,
133137 topologyInUse : true ,
134- expectedTypes : []csi.PluginCapability_Service_Type {
138+ expectedServiceTypes : []csi.PluginCapability_Service_Type {
135139 csi .PluginCapability_Service_CONTROLLER_SERVICE ,
136140 csi .PluginCapability_Service_GROUP_CONTROLLER_SERVICE ,
137141 csi .PluginCapability_Service_VOLUME_ACCESSIBILITY_CONSTRAINTS ,
138142 },
143+ expectedExpansionTypes : []csi.PluginCapability_VolumeExpansion_Type {
144+ csi .PluginCapability_VolumeExpansion_ONLINE ,
145+ },
139146 },
140147 }
141148
@@ -145,13 +152,23 @@ func TestGetPluginCapabilities(t *testing.T) {
145152 topologyInUse : tc .topologyInUse ,
146153 }
147154 resp , err := plugin .GetPluginCapabilities (context .Background (), & csi.GetPluginCapabilitiesRequest {})
155+
148156 assert .NoError (t , err )
149157 assert .NotNil (t , resp )
150- var gotTypes []csi.PluginCapability_Service_Type
151- for _ , cap := range resp .Capabilities {
152- gotTypes = append (gotTypes , cap .GetService ().GetType ())
158+
159+ var gotServiceTypes []csi.PluginCapability_Service_Type
160+ var gotExpansionTypes []csi.PluginCapability_VolumeExpansion_Type
161+
162+ for _ , capability := range resp .Capabilities {
163+ if capability .GetService () != nil {
164+ gotServiceTypes = append (gotServiceTypes , capability .GetService ().GetType ())
165+ } else if capability .GetVolumeExpansion () != nil {
166+ gotExpansionTypes = append (gotExpansionTypes , capability .GetVolumeExpansion ().GetType ())
167+ }
153168 }
154- assert .ElementsMatch (t , tc .expectedTypes , gotTypes )
169+
170+ assert .ElementsMatch (t , tc .expectedServiceTypes , gotServiceTypes )
171+ assert .ElementsMatch (t , tc .expectedExpansionTypes , gotExpansionTypes )
155172 })
156173 }
157174}
0 commit comments