@@ -251,67 +251,6 @@ func TestCheckVSCReadiness(t *testing.T) {
251251 }
252252 })
253253 }
254-
255- // Error injection tests for tryDeleteOriginalVSC
256- t .Run ("Get returns non-NotFound error, returns false" , func (t * testing.T ) {
257- errClient := & fakeClientWithErrors {
258- Client : velerotest .NewFakeControllerRuntimeClient (t ),
259- getError : fmt .Errorf ("connection refused" ),
260- }
261- p := & volumeSnapshotContentDeleteItemAction {
262- log : logrus .StandardLogger (),
263- crClient : errClient ,
264- }
265- require .False (t , p .tryDeleteOriginalVSC (t .Context (), "some-vsc" ))
266- })
267-
268- t .Run ("Patch fails, returns false" , func (t * testing.T ) {
269- realClient := velerotest .NewFakeControllerRuntimeClient (t )
270- vsc := & snapshotv1api.VolumeSnapshotContent {
271- ObjectMeta : metav1.ObjectMeta {Name : "patch-fail-vsc" },
272- Spec : snapshotv1api.VolumeSnapshotContentSpec {
273- DeletionPolicy : snapshotv1api .VolumeSnapshotContentRetain ,
274- Driver : "disk.csi.azure.com" ,
275- Source : snapshotv1api.VolumeSnapshotContentSource {SnapshotHandle : stringPtr ("snap-789" )},
276- VolumeSnapshotRef : corev1api.ObjectReference {Name : "vs-3" , Namespace : "default" },
277- },
278- }
279- require .NoError (t , realClient .Create (t .Context (), vsc ))
280-
281- errClient := & fakeClientWithErrors {
282- Client : realClient ,
283- patchError : fmt .Errorf ("patch forbidden" ),
284- }
285- p := & volumeSnapshotContentDeleteItemAction {
286- log : logrus .StandardLogger (),
287- crClient : errClient ,
288- }
289- require .False (t , p .tryDeleteOriginalVSC (t .Context (), "patch-fail-vsc" ))
290- })
291-
292- t .Run ("Delete fails, returns false" , func (t * testing.T ) {
293- realClient := velerotest .NewFakeControllerRuntimeClient (t )
294- vsc := & snapshotv1api.VolumeSnapshotContent {
295- ObjectMeta : metav1.ObjectMeta {Name : "delete-fail-vsc" },
296- Spec : snapshotv1api.VolumeSnapshotContentSpec {
297- DeletionPolicy : snapshotv1api .VolumeSnapshotContentDelete ,
298- Driver : "disk.csi.azure.com" ,
299- Source : snapshotv1api.VolumeSnapshotContentSource {SnapshotHandle : stringPtr ("snap-999" )},
300- VolumeSnapshotRef : corev1api.ObjectReference {Name : "vs-4" , Namespace : "default" },
301- },
302- }
303- require .NoError (t , realClient .Create (t .Context (), vsc ))
304-
305- errClient := & fakeClientWithErrors {
306- Client : realClient ,
307- deleteError : fmt .Errorf ("delete forbidden" ),
308- }
309- p := & volumeSnapshotContentDeleteItemAction {
310- log : logrus .StandardLogger (),
311- crClient : errClient ,
312- }
313- require .False (t , p .tryDeleteOriginalVSC (t .Context (), "delete-fail-vsc" ))
314- })
315254}
316255
317256func TestVSCExecute_CreateSleepDeleteOrder (t * testing.T ) {
@@ -346,11 +285,3 @@ func TestVSCExecute_CreateSleepDeleteOrder(t *testing.T) {
346285 require .NoError (t , err )
347286 require .Equal (t , []string {"create" , "sleep" , "delete" }, events )
348287}
349-
350- func boolPtr (b bool ) * bool {
351- return & b
352- }
353-
354- func stringPtr (s string ) * string {
355- return & s
356- }
0 commit comments