(t *testing.T)
| 175 | } |
| 176 | |
| 177 | func TestHandlersForRuntimeOps(t *testing.T) { |
| 178 | emptyDir, _ := ioutil.TempDir("./tmp", "test") |
| 179 | defer os.RemoveAll(emptyDir) |
| 180 | |
| 181 | cfg := cbgt.NewCfgMem() |
| 182 | meh := &TestMEH{} |
| 183 | mgr := cbgt.NewManager(cbgt.VERSION, cfg, cbgt.NewUUID(), |
| 184 | nil, "", 1, "", ":1000", emptyDir, "some-datasource", meh) |
| 185 | mgr.Start("wanted") |
| 186 | mgr.Kick("test-start-kick") |
| 187 | |
| 188 | mr, _ := cbgt.NewMsgRing(os.Stderr, 1000) |
| 189 | mr.Write([]byte("hello")) |
| 190 | mr.Write([]byte("world")) |
| 191 | |
| 192 | router, _, err := NewRESTRouter("v0", mgr, "static", "", mr, nil) |
| 193 | if err != nil || router == nil { |
| 194 | t.Errorf("no mux router") |
| 195 | } |
| 196 | |
| 197 | tests := []*RESTHandlerTest{ |
| 198 | { |
| 199 | Path: "/api/runtime", |
| 200 | Method: "GET", |
| 201 | Params: nil, |
| 202 | Body: nil, |
| 203 | Status: http.StatusOK, |
| 204 | ResponseMatch: map[string]bool{ |
| 205 | "arch": true, |
| 206 | "go": true, |
| 207 | "GOMAXPROCS": true, |
| 208 | "GOROOT": true, |
| 209 | }, |
| 210 | }, |
| 211 | { |
| 212 | Path: "/api/runtime/args", |
| 213 | Method: "GET", |
| 214 | Params: nil, |
| 215 | Body: nil, |
| 216 | Status: http.StatusOK, |
| 217 | ResponseMatch: map[string]bool{ |
| 218 | // Actual production args are different from "go test" context. |
| 219 | }, |
| 220 | }, |
| 221 | { |
| 222 | Path: "/api/runtime/gc", |
| 223 | Method: "POST", |
| 224 | Params: nil, |
| 225 | Body: nil, |
| 226 | Status: http.StatusOK, |
| 227 | ResponseBody: []byte(nil), |
| 228 | }, |
| 229 | { |
| 230 | Path: "/api/runtime/statsMem", |
| 231 | Method: "GET", |
| 232 | Params: nil, |
| 233 | Body: nil, |
| 234 | Status: http.StatusOK, |
nothing calls this directly
no test coverage detected