@@ -22,6 +22,8 @@ const volumeCreateFixture string = `
2222 "name": "myvolume",
2323 "size": "500G",
2424 "path": {},
25+ "type": "csi",
26+ "parameters": {},
2527 "created": "2020-08-26T00:00:00UTC",
2628 "updated": "2020-08-26T00:00:00UTC"
2729}
@@ -37,6 +39,8 @@ const volumeExpandFixture string = `
3739 "name": "myvolume",
3840 "size": "500G",
3941 "path": {},
42+ "type": "csi",
43+ "parameters": {},
4044 "created": "2020-08-26T00:00:00UTC",
4145 "updated": "2020-08-26T00:00:00UTC"
4246}
@@ -55,13 +59,30 @@ const volumesFixture string = `
5559 "name": "myvolume",
5660 "size": "500G",
5761 "path": {},
62+ "type": "csi",
63+ "parameters": {},
5864 "created": "2020-08-26T00:00:00UTC",
5965 "updated": "2020-08-26T00:00:00UTC"
6066 }
6167 ]
6268}
6369`
6470
71+ const volumeGetFixture string = `
72+ {
73+ "uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
74+ "owner": "test",
75+ "app": "example-go",
76+ "name": "myvolume",
77+ "size": "500G",
78+ "path": {},
79+ "type": "csi",
80+ "parameters": {},
81+ "created": "2020-08-26T00:00:00UTC",
82+ "updated": "2020-08-26T00:00:00UTC"
83+ }
84+ `
85+
6586const volumeMountFixture string = `
6687{
6788 "uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75",
@@ -73,6 +94,8 @@ const volumeMountFixture string = `
7394 "cmd": "/data/cmd1",
7495 "web": "/data/web1"
7596 },
97+ "type": "csi",
98+ "parameters": {},
7699 "created": "2020-08-26T00:00:00UTC",
77100 "updated": "2020-08-26T00:00:00UTC"
78101}
@@ -86,6 +109,8 @@ const volumeUnmountFixture string = `
86109 "name": "myvolume",
87110 "size": "500G",
88111 "path": {},
112+ "type": "csi",
113+ "parameters": {},
89114 "created": "2020-08-26T00:00:00UTC",
90115 "updated": "2020-08-26T00:00:00UTC"
91116}
@@ -121,6 +146,11 @@ func (f *fakeHTTPServer) ServeHTTP(res http.ResponseWriter, req *http.Request) {
121146 return
122147 }
123148
149+ if req .URL .Path == "/v2/apps/example-go/volumes/myvolume/" && req .Method == "GET" {
150+ res .Write ([]byte (volumeGetFixture ))
151+ return
152+ }
153+
124154 // Expand
125155 if req .URL .Path == "/v2/apps/example-go/volumes/myvolume/" && req .Method == "PATCH" {
126156 body , err := io .ReadAll (req .Body )
@@ -205,14 +235,16 @@ func TestVolumesCreate(t *testing.T) {
205235 t .Parallel ()
206236
207237 expected := api.Volume {
208- UUID : "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75" ,
209- Owner : "test" ,
210- App : "example-go" ,
211- Name : "myvolume" ,
212- Size : "500G" ,
213- Path : map [string ]interface {}{},
214- Created : "2020-08-26T00:00:00UTC" ,
215- Updated : "2020-08-26T00:00:00UTC" ,
238+ UUID : "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75" ,
239+ Owner : "test" ,
240+ App : "example-go" ,
241+ Name : "myvolume" ,
242+ Size : "500G" ,
243+ Path : map [string ]interface {}{},
244+ Type : "csi" ,
245+ Parameters : map [string ]interface {}{},
246+ Created : "2020-08-26T00:00:00UTC" ,
247+ Updated : "2020-08-26T00:00:00UTC" ,
216248 }
217249
218250 handler := fakeHTTPServer {}
@@ -242,14 +274,16 @@ func TestVolumesExpand(t *testing.T) {
242274 t .Parallel ()
243275
244276 expected := api.Volume {
245- UUID : "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75" ,
246- Owner : "test" ,
247- App : "example-go" ,
248- Name : "myvolume" ,
249- Size : "500G" ,
250- Path : map [string ]interface {}{},
251- Created : "2020-08-26T00:00:00UTC" ,
252- Updated : "2020-08-26T00:00:00UTC" ,
277+ UUID : "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75" ,
278+ Owner : "test" ,
279+ App : "example-go" ,
280+ Name : "myvolume" ,
281+ Size : "500G" ,
282+ Path : map [string ]interface {}{},
283+ Type : "csi" ,
284+ Parameters : map [string ]interface {}{},
285+ Created : "2020-08-26T00:00:00UTC" ,
286+ Updated : "2020-08-26T00:00:00UTC" ,
253287 }
254288
255289 handler := fakeHTTPServer {}
@@ -297,14 +331,16 @@ func TestVolumesList(t *testing.T) {
297331
298332 expected := api.Volumes {
299333 {
300- UUID : "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75" ,
301- App : "example-go" ,
302- Owner : "test" ,
303- Name : "myvolume" ,
304- Path : map [string ]interface {}{},
305- Size : "500G" ,
306- Created : "2020-08-26T00:00:00UTC" ,
307- Updated : "2020-08-26T00:00:00UTC" ,
334+ UUID : "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75" ,
335+ App : "example-go" ,
336+ Owner : "test" ,
337+ Name : "myvolume" ,
338+ Path : map [string ]interface {}{},
339+ Size : "500G" ,
340+ Type : "csi" ,
341+ Parameters : map [string ]interface {}{},
342+ Created : "2020-08-26T00:00:00UTC" ,
343+ Updated : "2020-08-26T00:00:00UTC" ,
308344 },
309345 }
310346
@@ -328,6 +364,39 @@ func TestVolumesList(t *testing.T) {
328364 }
329365}
330366
367+ func TestVolumeGet (t * testing.T ) {
368+ expected := api.Volume {
369+ UUID : "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75" ,
370+ App : "example-go" ,
371+ Owner : "test" ,
372+ Name : "myvolume" ,
373+ Path : map [string ]interface {}{},
374+ Size : "500G" ,
375+ Type : "csi" ,
376+ Parameters : map [string ]interface {}{},
377+ Created : "2020-08-26T00:00:00UTC" ,
378+ Updated : "2020-08-26T00:00:00UTC" ,
379+ }
380+ handler := fakeHTTPServer {}
381+ server := httptest .NewServer (& handler )
382+ defer server .Close ()
383+
384+ drycc , err := drycc .New (false , server .URL , "abc" )
385+ if err != nil {
386+ t .Fatal (err )
387+ }
388+
389+ actual , err := Get (drycc , "example-go" , "myvolume" )
390+
391+ if err != nil {
392+ t .Fatal (err )
393+ }
394+
395+ if ! reflect .DeepEqual (expected , actual ) {
396+ t .Error (fmt .Errorf ("Expected %v, Got %v" , expected , actual ))
397+ }
398+ }
399+
331400func TestVolumeMount (t * testing.T ) {
332401 t .Parallel ()
333402
@@ -348,10 +417,12 @@ func TestVolumeMount(t *testing.T) {
348417 "cmd" : "/data/cmd1" ,
349418 "web" : "/data/web1" ,
350419 },
351- Size : "500G" ,
352- Created : "2020-08-26T00:00:00UTC" ,
353- Updated : "2020-08-26T00:00:00UTC" ,
354- UUID : "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75" ,
420+ Size : "500G" ,
421+ Type : "csi" ,
422+ Parameters : map [string ]interface {}{},
423+ Created : "2020-08-26T00:00:00UTC" ,
424+ Updated : "2020-08-26T00:00:00UTC" ,
425+ UUID : "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75" ,
355426 }
356427
357428 volumeVars := api.Volume {
@@ -384,14 +455,16 @@ func TestVolumeUnmount(t *testing.T) {
384455 }
385456
386457 expected := api.Volume {
387- Name : "myvolume" ,
388- Owner : "test" ,
389- App : "unmount-test" ,
390- Path : map [string ]interface {}{},
391- Size : "500G" ,
392- Created : "2020-08-26T00:00:00UTC" ,
393- Updated : "2020-08-26T00:00:00UTC" ,
394- UUID : "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75" ,
458+ Name : "myvolume" ,
459+ Owner : "test" ,
460+ App : "unmount-test" ,
461+ Path : map [string ]interface {}{},
462+ Size : "500G" ,
463+ Type : "csi" ,
464+ Parameters : map [string ]interface {}{},
465+ Created : "2020-08-26T00:00:00UTC" ,
466+ Updated : "2020-08-26T00:00:00UTC" ,
467+ UUID : "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75" ,
395468 }
396469
397470 volumeVars := api.Volume {
0 commit comments