@@ -191,60 +191,45 @@ func TestNovaAPI_GetAllFlavors(t *testing.T) {
191
191
}
192
192
}
193
193
194
- func TestNovaAPI_GetChangedMigrations (t * testing.T ) {
195
- tests := []struct {
196
- name string
197
- time * time.Time
198
- }{
199
- {"nil" , nil },
200
- {"time" , & time.Time {}},
201
- }
202
- for _ , tt := range tests {
203
- handler := func (w http.ResponseWriter , r * http.Request ) {
204
- if tt .time == nil {
205
- // Check that the changes-since query parameter is not set.
206
- if r .URL .Query ().Get ("changes-since" ) != "" {
207
- t .Fatalf ("expected no changes-since query parameter, got %s" , r .URL .Query ().Get ("changes-since" ))
208
- }
209
- } else {
210
- if r .URL .Query ().Get ("changes-since" ) != tt .time .Format (time .RFC3339 ) {
211
- t .Fatalf ("expected changes-since query parameter to be %s, got %s" , tt .time .Format (time .RFC3339 ), r .URL .Query ().Get ("changes-since" ))
212
- }
213
- }
214
- w .Header ().Add ("Content-Type" , "application/json" )
215
- w .WriteHeader (http .StatusOK )
216
- resp := struct {
217
- Migrations []Migration `json:"migrations"`
218
- Links []struct {
219
- Rel string `json:"rel"`
220
- Href string `json:"href"`
221
- } `json:"migrations_links"`
222
- }{
223
- Migrations : []Migration {{ID : 1 , SourceCompute : "host1" , DestCompute : "host2" , Status : "completed" }},
224
- }
225
- if err := json .NewEncoder (w ).Encode (resp ); err != nil {
226
- t .Fatalf ("failed to write response: %v" , err )
227
- }
194
+ func TestNovaAPI_GetAllMigrations (t * testing.T ) {
195
+ handler := func (w http.ResponseWriter , r * http.Request ) {
196
+ if r .URL .Query ().Get ("changes-since" ) != "" {
197
+ t .Fatalf ("expected no changes-since query parameter, got %s" , r .URL .Query ().Get ("changes-since" ))
228
198
}
229
- server , k := setupNovaMockServer (handler )
230
- defer server .Close ()
199
+ w .Header ().Add ("Content-Type" , "application/json" )
200
+ w .WriteHeader (http .StatusOK )
201
+ resp := struct {
202
+ Migrations []Migration `json:"migrations"`
203
+ Links []struct {
204
+ Rel string `json:"rel"`
205
+ Href string `json:"href"`
206
+ } `json:"migrations_links"`
207
+ }{
208
+ Migrations : []Migration {{ID : 1 , SourceCompute : "host1" , DestCompute : "host2" , Status : "completed" }},
209
+ }
210
+ if err := json .NewEncoder (w ).Encode (resp ); err != nil {
211
+ t .Fatalf ("failed to write response: %v" , err )
212
+ }
213
+ }
231
214
232
- mon := sync. Monitor {}
233
- conf := NovaConf { Availability : "public" }
215
+ server , k := setupNovaMockServer ( handler )
216
+ defer server . Close ()
234
217
235
- api := NewNovaAPI ( mon , k , conf ).( * novaAPI )
236
- api . Init ( t . Context ())
218
+ mon := sync. Monitor {}
219
+ conf := NovaConf { Availability : "public" }
237
220
238
- ctx := t .Context ()
239
- migrations , err := api .GetChangedMigrations (ctx , tt .time )
240
- if err != nil {
241
- t .Fatalf ("expected no error, got %v" , err )
242
- }
243
- if len (migrations ) != 1 {
244
- t .Fatalf ("expected 1 migration, got %d" , len (migrations ))
245
- }
246
- if migrations [0 ].ID != 1 || migrations [0 ].SourceCompute != "host1" || migrations [0 ].DestCompute != "host2" || migrations [0 ].Status != "completed" {
247
- t .Errorf ("unexpected migration data: %+v" , migrations [0 ])
248
- }
221
+ api := NewNovaAPI (mon , k , conf ).(* novaAPI )
222
+ api .Init (t .Context ())
223
+
224
+ ctx := t .Context ()
225
+ migrations , err := api .GetAllMigrations (ctx )
226
+ if err != nil {
227
+ t .Fatalf ("expected no error, got %v" , err )
228
+ }
229
+ if len (migrations ) != 1 {
230
+ t .Fatalf ("expected 1 migration, got %d" , len (migrations ))
231
+ }
232
+ if migrations [0 ].ID != 1 || migrations [0 ].SourceCompute != "host1" || migrations [0 ].DestCompute != "host2" || migrations [0 ].Status != "completed" {
233
+ t .Errorf ("unexpected migration data: %+v" , migrations [0 ])
249
234
}
250
235
}
0 commit comments