-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsnapshot_test.go
46 lines (42 loc) · 1.41 KB
/
snapshot_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
package vultr
import (
"github.com/pearkes/digitalocean/testutil"
)
import . "github.com/motain/gocheck"
var snapshot_createResponses = testutil.ResponseMap{
"/v1/snapshot/create": makeResp(`{ "SNAPSHOTID": "5359435d28b9a" }`),
}
var snapshot_getResponses = testutil.ResponseMap{
"/v1/snapshot/list": makeResp(`{
"5421de1839f36" : { "SNAPSHOTID" : "5421de1839f36",
"date_created" : "2014-09-23 16:54:48",
"description" : "test",
"size" : "16106127360",
"status" : "complete"
},
"5422e5396566a" : { "SNAPSHOTID" : "5422e5396566a",
"date_created" : "2014-09-24 11:37:29",
"description" : "mysnapsnot-1411572827",
"size" : "16106127360",
"status" : "complete"
}
}`)}
func (s *S) Test_CreateSnapshot(c *C) {
testServer.ResponseMap(1,snapshot_createResponses)
id,err := s.client.CreateSnapshot("576965","Test snapshot")
reqs := testServer.WaitRequests(1)
c.Assert(err, IsNil)
c.Assert(id,Equals,"5359435d28b9a")
c.Assert(reqs[0].Form.Get("SUBID"),Equals,"576965")
}
func (s *S) Test_GetSnapshot(c *C) {
testServer.ResponseMap(1,snapshot_getResponses)
snap,err := s.client.GetSnapshot("5422e5396566a")
c.Assert(err, IsNil)
c.Assert(snap.Size,Equals,"16106127360")
}
func (s *S) Test_GetSnapshot_err(c *C) {
testServer.ResponseMap(1,snapshot_getResponses)
_,err := s.client.GetSnapshot("5359435dc1dd3")
c.Assert(err, ErrorMatches, "Snapshot not found")
}