@@ -12,7 +12,7 @@ func TestBlockStorageServiceHandler_Create(t *testing.T) {
1212 defer teardown ()
1313
1414 mux .HandleFunc ("/v2/blocks" , func (writer http.ResponseWriter , request * http.Request ) {
15- response := `{"block":{"id":"123456","cost":10,"status":"active","size_gb":100,"region":"ewr","attached_to_instance":"","date_created":"01-01-1960","label":"mylabel", "mount_id": "ewr-123abc", "block_type": "test"}}`
15+ response := `{"block":{"id":"123456","cost":10,"pending_charges":2.5," status":"active","size_gb":100,"region":"ewr","attached_to_instance":"","attached_to_instance_ip":"","attached_to_instance_label":""," date_created":"01-01-1960","label":"mylabel", "mount_id": "ewr-123abc", "block_type": "test", "os_id": 0, "snapshot_id": "", "bootable": false }}`
1616 fmt .Fprint (writer , response )
1717 })
1818 blockReq := & BlockStorageCreate {
@@ -27,16 +27,22 @@ func TestBlockStorageServiceHandler_Create(t *testing.T) {
2727 }
2828
2929 expected := & BlockStorage {
30- ID : "123456" ,
31- Cost : 10 ,
32- Status : "active" ,
33- SizeGB : 100 ,
34- Region : "ewr" ,
35- DateCreated : "01-01-1960" ,
36- AttachedToInstance : "" ,
37- Label : "mylabel" ,
38- MountID : "ewr-123abc" ,
39- BlockType : "test" ,
30+ ID : "123456" ,
31+ Cost : 10 ,
32+ PendingCharges : 2.5 ,
33+ Status : "active" ,
34+ SizeGB : 100 ,
35+ Region : "ewr" ,
36+ DateCreated : "01-01-1960" ,
37+ AttachedToInstance : "" ,
38+ AttachedToInstanceIP : "" ,
39+ AttachedToInstanceLabel : "" ,
40+ Label : "mylabel" ,
41+ MountID : "ewr-123abc" ,
42+ BlockType : "test" ,
43+ OSID : 0 ,
44+ SnapshotID : "" ,
45+ Bootable : false ,
4046 }
4147
4248 if ! reflect .DeepEqual (blockStorage , expected ) {
@@ -49,7 +55,7 @@ func TestBlockStorageServiceHandler_Get(t *testing.T) {
4955 defer teardown ()
5056
5157 mux .HandleFunc ("/v2/blocks/123456" , func (writer http.ResponseWriter , request * http.Request ) {
52- response := `{"block":{"id":"123456","cost":10,"status":"active","size_gb":100,"region":"ewr","attached_to_instance":"","date_created":"01-01-1960","label":"mylabel", "mount_id": "123abc", "block_type": "test"}}`
58+ response := `{"block":{"id":"123456","cost":10,"pending_charges":2.5," status":"active","size_gb":100,"region":"ewr","attached_to_instance":"","attached_to_instance_ip":"","attached_to_instance_label":""," date_created":"01-01-1960","label":"mylabel", "mount_id": "ewr- 123abc", "block_type": "test", "os_id": 0, "snapshot_id": "", "bootable": false }}`
5359 fmt .Fprint (writer , response )
5460 })
5561
@@ -59,20 +65,26 @@ func TestBlockStorageServiceHandler_Get(t *testing.T) {
5965 }
6066
6167 expected := & BlockStorage {
62- ID : "123456" ,
63- Cost : 10 ,
64- Status : "active" ,
65- SizeGB : 100 ,
66- Region : "ewr" ,
67- DateCreated : "01-01-1960" ,
68- AttachedToInstance : "" ,
69- Label : "mylabel" ,
70- MountID : "123abc" ,
71- BlockType : "test" ,
68+ ID : "123456" ,
69+ Cost : 10 ,
70+ PendingCharges : 2.5 ,
71+ Status : "active" ,
72+ SizeGB : 100 ,
73+ Region : "ewr" ,
74+ DateCreated : "01-01-1960" ,
75+ AttachedToInstance : "" ,
76+ AttachedToInstanceIP : "" ,
77+ AttachedToInstanceLabel : "" ,
78+ Label : "mylabel" ,
79+ MountID : "ewr-123abc" ,
80+ BlockType : "test" ,
81+ OSID : 0 ,
82+ SnapshotID : "" ,
83+ Bootable : false ,
7284 }
7385
7486 if ! reflect .DeepEqual (blockStorage , expected ) {
75- t .Errorf ("BlockStorage.Create returned %+v, expected %+v" , blockStorage , expected )
87+ t .Errorf ("BlockStorage.Get returned %+v, expected %+v" , blockStorage , expected )
7688 }
7789}
7890
@@ -89,7 +101,7 @@ func TestBlockStorageServiceHandler_Update(t *testing.T) {
89101 }
90102 err := client .BlockStorage .Update (ctx , "123456" , blockUpdate )
91103 if err != nil {
92- t .Errorf ("BlockStorage.SetLabel returned %+v, expected %+v" , err , nil )
104+ t .Errorf ("BlockStorage.Update returned %+v, expected %+v" , err , nil )
93105 }
94106}
95107
@@ -112,32 +124,38 @@ func TestBlockStorageServiceHandler_List(t *testing.T) {
112124 defer teardown ()
113125
114126 mux .HandleFunc ("/v2/blocks" , func (writer http.ResponseWriter , request * http.Request ) {
115- response := `{"blocks":[{"id":"123456","cost":10,"status":"active","size_gb":100,"region":"ewr","attached_to_instance":"","date_created":"01-01-1960","label":"mylabel", "mount_id": "123abc", "block_type": "test"}],"meta":{"total":1,"links":{"next":"thisismycusror","prev":""}}}`
127+ response := `{"blocks":[{"id":"123456","cost":10,"pending_charges":2.5," status":"active","size_gb":100,"region":"ewr","attached_to_instance":"","attached_to_instance_ip":"","attached_to_instance_label":""," date_created":"01-01-1960","label":"mylabel", "mount_id": "ewr- 123abc", "block_type": "test", "os_id": 0, "snapshot_id": "", "bootable": false }],"meta":{"total":1,"links":{"next":"thisismycusror","prev":""}}}`
116128 fmt .Fprint (writer , response )
117129 })
118130
119131 blockStorage , meta , _ , err := client .BlockStorage .List (ctx , nil )
120132 if err != nil {
121- t .Errorf ("BlockStorage.Create returned error: %v" , err )
133+ t .Errorf ("BlockStorage.List returned error: %v" , err )
122134 }
123135
124136 expected := []BlockStorage {
125137 {
126- ID : "123456" ,
127- Cost : 10 ,
128- Status : "active" ,
129- SizeGB : 100 ,
130- Region : "ewr" ,
131- DateCreated : "01-01-1960" ,
132- AttachedToInstance : "" ,
133- Label : "mylabel" ,
134- MountID : "123abc" ,
135- BlockType : "test" ,
138+ ID : "123456" ,
139+ Cost : 10 ,
140+ PendingCharges : 2.5 ,
141+ Status : "active" ,
142+ SizeGB : 100 ,
143+ Region : "ewr" ,
144+ DateCreated : "01-01-1960" ,
145+ AttachedToInstance : "" ,
146+ AttachedToInstanceIP : "" ,
147+ AttachedToInstanceLabel : "" ,
148+ Label : "mylabel" ,
149+ MountID : "ewr-123abc" ,
150+ BlockType : "test" ,
151+ OSID : 0 ,
152+ SnapshotID : "" ,
153+ Bootable : false ,
136154 },
137155 }
138156
139157 if ! reflect .DeepEqual (blockStorage , expected ) {
140- t .Errorf ("BlockStorage.Create returned %+v, expected %+v" , blockStorage , expected )
158+ t .Errorf ("BlockStorage.List returned %+v, expected %+v" , blockStorage , expected )
141159 }
142160
143161 expectedMeta := & Meta {
@@ -149,7 +167,7 @@ func TestBlockStorageServiceHandler_List(t *testing.T) {
149167 }
150168
151169 if ! reflect .DeepEqual (meta , expectedMeta ) {
152- t .Errorf ("User .List meta returned %+v, expected %+v" , meta , expectedMeta )
170+ t .Errorf ("BlockStorage .List meta returned %+v, expected %+v" , meta , expectedMeta )
153171 }
154172}
155173
0 commit comments