MCPcopy Create free account
hub / github.com/couchbase/cbft / TestHandlersForRuntimeOps

Function TestHandlersForRuntimeOps

rest_test.go:177–263  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

175}
176
177func 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,

Callers

nothing calls this directly

Calls 3

NewRESTRouterFunction · 0.85
testRESTHandlersFunction · 0.85
WriteMethod · 0.45

Tested by

no test coverage detected