(t *testing.T)
| 263 | } |
| 264 | |
| 265 | func TestHandlersForEmptyManager(t *testing.T) { |
| 266 | emptyDir, _ := ioutil.TempDir("./tmp", "test") |
| 267 | defer os.RemoveAll(emptyDir) |
| 268 | |
| 269 | cfg := cbgt.NewCfgMem() |
| 270 | meh := &TestMEH{} |
| 271 | mgr := cbgt.NewManager(cbgt.VERSION, cfg, cbgt.NewUUID(), |
| 272 | nil, "", 1, "", ":1000", emptyDir, "some-datasource", meh) |
| 273 | mgr.Start("wanted") |
| 274 | mgr.Kick("test-start-kick") |
| 275 | |
| 276 | mr, _ := cbgt.NewMsgRing(os.Stderr, 1000) |
| 277 | mr.Write([]byte("hello")) |
| 278 | mr.Write([]byte("world")) |
| 279 | |
| 280 | mgr.AddEvent([]byte(`"fizz"`)) |
| 281 | mgr.AddEvent([]byte(`"buzz"`)) |
| 282 | |
| 283 | router, _, err := NewRESTRouter("v0", mgr, "static", "", mr, nil) |
| 284 | if err != nil || router == nil { |
| 285 | t.Errorf("no mux router") |
| 286 | } |
| 287 | |
| 288 | tests := []*RESTHandlerTest{ |
| 289 | { |
| 290 | Desc: "log on empty msg ring", |
| 291 | Path: "/api/log", |
| 292 | Method: "GET", |
| 293 | Params: nil, |
| 294 | Body: nil, |
| 295 | Status: http.StatusOK, |
| 296 | ResponseBody: []byte(`{"messages":["hello","world"],"events":["fizz","buzz"]}`), |
| 297 | }, |
| 298 | { |
| 299 | Desc: "cfg on empty manaager", |
| 300 | Path: "/api/cfg", |
| 301 | Method: "GET", |
| 302 | Params: nil, |
| 303 | Body: nil, |
| 304 | Status: http.StatusOK, |
| 305 | ResponseMatch: map[string]bool{ |
| 306 | `"status":"ok"`: true, |
| 307 | `"indexDefs":null`: true, |
| 308 | `"nodeDefsKnown":{`: true, |
| 309 | `"nodeDefsWanted":{`: true, |
| 310 | `"planPIndexes":null`: true, |
| 311 | }, |
| 312 | }, |
| 313 | { |
| 314 | Desc: "cfg refresh on empty, unchanged manager", |
| 315 | Path: "/api/cfgRefresh", |
| 316 | Method: "POST", |
| 317 | Params: nil, |
| 318 | Body: nil, |
| 319 | Status: http.StatusOK, |
| 320 | ResponseMatch: map[string]bool{ |
| 321 | `"status":"ok"`: true, |
| 322 | }, |
nothing calls this directly
no test coverage detected