@@ -201,28 +201,21 @@ func TestRemovePrefixedCSIParams(t *testing.T) {
201
201
}
202
202
}
203
203
204
- func TestIsDefaultAnnotation (t * testing.T ) {
204
+ func TestIsVolumeSnapshotClassDefaultAnnotation (t * testing.T ) {
205
205
testcases := []struct {
206
206
name string
207
- typeMeta metav1.TypeMeta
208
207
objectMeta metav1.ObjectMeta
209
208
isDefault bool
210
209
}{
211
210
{
212
211
name : "no default annotation in snapshot class" ,
213
- typeMeta : metav1.TypeMeta {
214
- Kind : "VolumeSnapshotClass" ,
215
- },
216
212
objectMeta : metav1.ObjectMeta {
217
- Annotations : map [ string ] string {} ,
213
+ Annotations : nil ,
218
214
},
219
215
isDefault : false ,
220
216
},
221
217
{
222
218
name : "with default annotation in snapshot class" ,
223
- typeMeta : metav1.TypeMeta {
224
- Kind : "VolumeSnapshotClass" ,
225
- },
226
219
objectMeta : metav1.ObjectMeta {
227
220
Annotations : map [string ]string {
228
221
IsDefaultSnapshotClassAnnotation : "true" ,
@@ -232,31 +225,38 @@ func TestIsDefaultAnnotation(t *testing.T) {
232
225
},
233
226
{
234
227
name : "with default=false annotation in snapshot class" ,
235
- typeMeta : metav1.TypeMeta {
236
- Kind : "VolumeSnapshotClass" ,
237
- },
238
228
objectMeta : metav1.ObjectMeta {
239
229
Annotations : map [string ]string {
240
230
IsDefaultSnapshotClassAnnotation : "false" ,
241
231
},
242
232
},
243
233
isDefault : false ,
244
234
},
235
+ }
236
+ for _ , tc := range testcases {
237
+ t .Logf ("test: %s" , tc .name )
238
+ isDefault := IsVolumeSnapshotClassDefaultAnnotation (tc .objectMeta )
239
+ if tc .isDefault != isDefault {
240
+ t .Fatalf ("default annotation on class incorrectly detected: %v != %v" , isDefault , tc .isDefault )
241
+ }
242
+ }
243
+ }
244
+
245
+ func TestIsVolumeGroupSnapshotClassDefaultAnnotation (t * testing.T ) {
246
+ testcases := []struct {
247
+ name string
248
+ objectMeta metav1.ObjectMeta
249
+ isDefault bool
250
+ }{
245
251
{
246
252
name : "no default annotation in group snapshot class" ,
247
- typeMeta : metav1.TypeMeta {
248
- Kind : "VolumeGroupSnapshotClass" ,
249
- },
250
253
objectMeta : metav1.ObjectMeta {
251
- Annotations : map [ string ] string {} ,
254
+ Annotations : nil ,
252
255
},
253
256
isDefault : false ,
254
257
},
255
258
{
256
259
name : "with default annotation in group snapshot class" ,
257
- typeMeta : metav1.TypeMeta {
258
- Kind : "VolumeGroupSnapshotClass" ,
259
- },
260
260
objectMeta : metav1.ObjectMeta {
261
261
Annotations : map [string ]string {
262
262
IsDefaultGroupSnapshotClassAnnotation : "true" ,
@@ -266,30 +266,17 @@ func TestIsDefaultAnnotation(t *testing.T) {
266
266
},
267
267
{
268
268
name : "with default=false annotation in group snapshot class" ,
269
- typeMeta : metav1.TypeMeta {
270
- Kind : "VolumeGroupSnapshotClass" ,
271
- },
272
269
objectMeta : metav1.ObjectMeta {
273
270
Annotations : map [string ]string {
274
271
IsDefaultGroupSnapshotClassAnnotation : "false" ,
275
272
},
276
273
},
277
274
isDefault : false ,
278
275
},
279
- {
280
- name : "unknown kind, not a snapshot or group snapshot class" ,
281
- typeMeta : metav1.TypeMeta {
282
- Kind : "PersistentVolume" ,
283
- },
284
- objectMeta : metav1.ObjectMeta {
285
- Annotations : map [string ]string {},
286
- },
287
- isDefault : false ,
288
- },
289
276
}
290
277
for _ , tc := range testcases {
291
278
t .Logf ("test: %s" , tc .name )
292
- isDefault := IsDefaultAnnotation ( tc . typeMeta , tc .objectMeta )
279
+ isDefault := IsVolumeGroupSnapshotClassDefaultAnnotation ( tc .objectMeta )
293
280
if tc .isDefault != isDefault {
294
281
t .Fatalf ("default annotation on class incorrectly detected: %v != %v" , isDefault , tc .isDefault )
295
282
}
0 commit comments