forked from AliyunContainerService/pouch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_volume_inspect_test.go
48 lines (38 loc) · 1.21 KB
/
api_volume_inspect_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"github.com/alibaba/pouch/test/environment"
"github.com/alibaba/pouch/test/request"
"github.com/go-check/check"
)
// APIVolumeInspectSuite is the test suite for volume inspect API.
type APIVolumeInspectSuite struct{}
func init() {
check.Suite(&APIVolumeInspectSuite{})
}
// SetUpTest does common setup in the beginning of each test.
func (suite *APIVolumeInspectSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)
}
// TestVolumeInspectOk tests if inspecting a volume is OK.
func (suite *APIVolumeInspectSuite) TestVolumeInspectOk(c *check.C) {
// Create a volume with the name "TestVolume".
vol := "TestVolume"
CreateVolumeOK(c, vol, "local", nil)
defer RemoveVolumeOK(c, vol)
// Test volume inspect feature.
path := "/volumes/" + vol
resp, err := request.Get(path)
c.Assert(err, check.IsNil)
CheckRespStatus(c, resp, 200)
// TODO: missing case
//
// add field check
}
// TestVolumeInspectNotFound tests if inspecting a nonexistent volume returns error.
func (suite *APIVolumeInspectSuite) TestVolumeInspectNotFound(c *check.C) {
vol := "NotExistentVolume"
path := "/volumes/" + vol
resp, err := request.Get(path)
c.Assert(err, check.IsNil)
CheckRespStatus(c, resp, 404)
}