@@ -25,6 +25,10 @@ import (
25
25
mountmanager "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/mount-manager"
26
26
)
27
27
28
+ const defaultVolumeID = "project/test001/zones/c1/disks/testDisk"
29
+ const defaultTargetPath = "/mnt/test"
30
+ const defaultStagingPath = "/staging"
31
+
28
32
func getTestGCEDriver (t * testing.T ) * GCEDriver {
29
33
gceDriver := GetGCEDriver ()
30
34
err := gceDriver .SetupGCEDriver (nil , mountmanager .NewFakeSafeMounter (), mountmanager .NewFakeDeviceUtils (), metadataservice .NewFakeService (), driver , "test-vendor" )
@@ -100,18 +104,18 @@ func TestNodePublishVolume(t *testing.T) {
100
104
{
101
105
name : "Valid request" ,
102
106
req : & csi.NodePublishVolumeRequest {
103
- VolumeId : "1" ,
104
- TargetPath : "/mnt/test" ,
105
- StagingTargetPath : "/staging" ,
107
+ VolumeId : defaultVolumeID ,
108
+ TargetPath : defaultTargetPath ,
109
+ StagingTargetPath : defaultStagingPath ,
106
110
Readonly : false ,
107
111
VolumeCapability : & csi.VolumeCapability {},
108
112
},
109
113
},
110
114
{
111
115
name : "Invalid request (No VolumeId)" ,
112
116
req : & csi.NodePublishVolumeRequest {
113
- TargetPath : "/mnt/test" ,
114
- StagingTargetPath : "/staging" ,
117
+ TargetPath : defaultTargetPath ,
118
+ StagingTargetPath : defaultStagingPath ,
115
119
Readonly : false ,
116
120
VolumeCapability : & csi.VolumeCapability {},
117
121
},
@@ -120,8 +124,8 @@ func TestNodePublishVolume(t *testing.T) {
120
124
{
121
125
name : "Invalid request (No TargetPath)" ,
122
126
req : & csi.NodePublishVolumeRequest {
123
- VolumeId : "1" ,
124
- StagingTargetPath : "/staging" ,
127
+ VolumeId : defaultVolumeID ,
128
+ StagingTargetPath : defaultStagingPath ,
125
129
Readonly : false ,
126
130
VolumeCapability : & csi.VolumeCapability {},
127
131
},
@@ -130,8 +134,8 @@ func TestNodePublishVolume(t *testing.T) {
130
134
{
131
135
name : "Invalid request (No StagingTargetPath)" ,
132
136
req : & csi.NodePublishVolumeRequest {
133
- VolumeId : "1" ,
134
- TargetPath : "/mnt/test" ,
137
+ VolumeId : defaultVolumeID ,
138
+ TargetPath : defaultTargetPath ,
135
139
Readonly : false ,
136
140
VolumeCapability : & csi.VolumeCapability {},
137
141
},
@@ -140,9 +144,9 @@ func TestNodePublishVolume(t *testing.T) {
140
144
{
141
145
name : "Invalid request (Nil VolumeCapability)" ,
142
146
req : & csi.NodePublishVolumeRequest {
143
- VolumeId : "1" ,
144
- TargetPath : "/mnt/test" ,
145
- StagingTargetPath : "/staging" ,
147
+ VolumeId : defaultVolumeID ,
148
+ TargetPath : defaultTargetPath ,
149
+ StagingTargetPath : defaultStagingPath ,
146
150
Readonly : false ,
147
151
VolumeCapability : nil ,
148
152
},
@@ -179,21 +183,21 @@ func TestNodeUnpublishVolume(t *testing.T) {
179
183
{
180
184
name : "Valid request" ,
181
185
req : & csi.NodeUnpublishVolumeRequest {
182
- VolumeId : "1" ,
183
- TargetPath : "/mnt/test" ,
186
+ VolumeId : defaultVolumeID ,
187
+ TargetPath : defaultTargetPath ,
184
188
},
185
189
},
186
190
{
187
191
name : "Invalid request (No VolumeId)" ,
188
192
req : & csi.NodeUnpublishVolumeRequest {
189
- TargetPath : "/mnt/test" ,
193
+ TargetPath : defaultTargetPath ,
190
194
},
191
195
expErrCode : codes .InvalidArgument ,
192
196
},
193
197
{
194
198
name : "Invalid request (No TargetPath)" ,
195
199
req : & csi.NodeUnpublishVolumeRequest {
196
- VolumeId : "1" ,
200
+ VolumeId : defaultVolumeID ,
197
201
},
198
202
expErrCode : codes .InvalidArgument ,
199
203
},
@@ -237,14 +241,14 @@ func TestNodeStageVolume(t *testing.T) {
237
241
name : "Valid request" ,
238
242
req : & csi.NodeStageVolumeRequest {
239
243
VolumeId : volumeID ,
240
- StagingTargetPath : "/staging" ,
244
+ StagingTargetPath : defaultStagingPath ,
241
245
VolumeCapability : & csi.VolumeCapability {},
242
246
},
243
247
},
244
248
{
245
249
name : "Invalid request (No VolumeId)" ,
246
250
req : & csi.NodeStageVolumeRequest {
247
- StagingTargetPath : "/staging" ,
251
+ StagingTargetPath : defaultStagingPath ,
248
252
VolumeCapability : & csi.VolumeCapability {},
249
253
},
250
254
expErrCode : codes .InvalidArgument ,
@@ -261,7 +265,7 @@ func TestNodeStageVolume(t *testing.T) {
261
265
name : "Invalid request (Nil VolumeCapability)" ,
262
266
req : & csi.NodeStageVolumeRequest {
263
267
VolumeId : volumeID ,
264
- StagingTargetPath : "/staging" ,
268
+ StagingTargetPath : defaultStagingPath ,
265
269
VolumeCapability : nil ,
266
270
},
267
271
expErrCode : codes .InvalidArgument ,
@@ -270,7 +274,7 @@ func TestNodeStageVolume(t *testing.T) {
270
274
name : "Invalid request (No Mount in capability)" ,
271
275
req : & csi.NodeStageVolumeRequest {
272
276
VolumeId : volumeID ,
273
- StagingTargetPath : "/staging" ,
277
+ StagingTargetPath : defaultStagingPath ,
274
278
VolumeCapability : cap ,
275
279
},
276
280
expErrCode : codes .Unimplemented ,
@@ -307,21 +311,21 @@ func TestNodeUnstageVolume(t *testing.T) {
307
311
{
308
312
name : "Valid request" ,
309
313
req : & csi.NodeUnstageVolumeRequest {
310
- VolumeId : "1" ,
311
- StagingTargetPath : "/staging" ,
314
+ VolumeId : defaultVolumeID ,
315
+ StagingTargetPath : defaultStagingPath ,
312
316
},
313
317
},
314
318
{
315
319
name : "Invalid request (No VolumeId)" ,
316
320
req : & csi.NodeUnstageVolumeRequest {
317
- StagingTargetPath : "/staging" ,
321
+ StagingTargetPath : defaultStagingPath ,
318
322
},
319
323
expErrCode : codes .InvalidArgument ,
320
324
},
321
325
{
322
326
name : "Invalid request (No StagingTargetPath)" ,
323
327
req : & csi.NodeUnstageVolumeRequest {
324
- VolumeId : "1" ,
328
+ VolumeId : defaultVolumeID ,
325
329
},
326
330
expErrCode : codes .InvalidArgument ,
327
331
},
0 commit comments