@@ -32,13 +32,15 @@ import (
3232 datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
3333 "github.com/fluid-cloudnative/fluid/pkg/common"
3434 "github.com/fluid-cloudnative/fluid/pkg/ddc/base"
35+ "github.com/fluid-cloudnative/fluid/pkg/utils/testutil"
3536)
3637
3738type TestCase struct {
3839 name string
3940 namespace string
4041 withRuntimeInfo bool
41- isDeleted bool
42+ pvDeleted bool
43+ pvcDeleted bool
4244 isErr bool
4345}
4446
@@ -78,7 +80,7 @@ func doTestCases(testCases []TestCase, resources []runtime.Object, t *testing.T)
7880 Name : fmt .Sprintf ("%s-%s" , engine .namespace , engine .name ),
7981 }
8082 _ = engine .Client .Get (context .TODO (), keyPV , pv )
81- if test .isDeleted != reflect .DeepEqual (nullPV , * pv ) {
83+ if test .pvDeleted != reflect .DeepEqual (nullPV , * pv ) {
8284 t .Errorf ("%s/%s withRuntimeInfo=%t: PV still exist after delete." , test .namespace , test .name , test .withRuntimeInfo )
8385 }
8486
@@ -89,13 +91,15 @@ func doTestCases(testCases []TestCase, resources []runtime.Object, t *testing.T)
8991 Namespace : engine .namespace ,
9092 }
9193 _ = engine .Client .Get (context .TODO (), keyPVC , pvc )
92- if test .isDeleted != reflect .DeepEqual (nullPVC , * pvc ) {
94+ if test .pvcDeleted != reflect .DeepEqual (nullPVC , * pvc ) {
9395 t .Errorf ("%s/%s withRuntimeInfo=%t: PVC still exist after delete." , test .namespace , test .name , test .withRuntimeInfo )
9496 }
9597 }
9698}
9799
98100func TestEFCEngine_DeleteVolume (t * testing.T ) {
101+ t .Setenv (testutil .FluidUnitTestEnv , "true" )
102+
99103 testPVInputs := []* v1.PersistentVolume {
100104 {
101105 ObjectMeta : metav1.ObjectMeta {
@@ -142,21 +146,24 @@ func TestEFCEngine_DeleteVolume(t *testing.T) {
142146 name : "efcdemo" ,
143147 namespace : "fluid" ,
144148 withRuntimeInfo : true ,
145- isDeleted : true ,
149+ pvDeleted : true ,
150+ pvcDeleted : true ,
146151 isErr : false ,
147152 },
148153 {
149154 name : "error" ,
150155 namespace : "fluid" ,
151156 withRuntimeInfo : true ,
152- isDeleted : false ,
157+ pvDeleted : false ,
158+ pvcDeleted : false ,
153159 isErr : true ,
154160 },
155161 {
156162 name : "efcdemo" ,
157163 namespace : "fluid" ,
158164 withRuntimeInfo : false ,
159- isDeleted : true ,
165+ pvDeleted : false ,
166+ pvcDeleted : true ,
160167 isErr : true ,
161168 },
162169 }
0 commit comments