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

Function TestHandlersForIndexControl

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

Source from the content-addressed store, hash-verified

2750}
2751
2752func TestHandlersForIndexControl(t *testing.T) {
2753 rest.RequestProxyStubFunc = func() bool {
2754 return false
2755 }
2756 emptyDir, _ := ioutil.TempDir("./tmp", "test")
2757 defer func() {
2758 os.RemoveAll(emptyDir)
2759 rest.RequestProxyStubFunc = nil
2760 }()
2761
2762 cfg := cbgt.NewCfgMem()
2763 meh := &TestMEH{}
2764 mgr := cbgt.NewManager(cbgt.VERSION, cfg, cbgt.NewUUID(),
2765 nil, "", 1, "", ":1000", emptyDir, "some-datasource", meh)
2766 mgr.Start("wanted")
2767 mgr.Kick("test-start-kick")
2768
2769 mr, _ := cbgt.NewMsgRing(os.Stderr, 1000)
2770 mr.Write([]byte("hello"))
2771 mr.Write([]byte("world"))
2772
2773 router, _, err := NewRESTRouter("v0", mgr, "static", "", mr, nil)
2774 if err != nil || router == nil {
2775 t.Errorf("no mux router")
2776 }
2777
2778 tests := []*RESTHandlerTest{
2779 {
2780 Desc: "ingestControl on not-an-index",
2781 Path: "/api/index/not-an-index/ingestControl/pause",
2782 Method: "POST",
2783 Params: nil,
2784 Body: nil,
2785 Status: 400,
2786 ResponseMatch: map[string]bool{
2787 `err`: true,
2788 },
2789 },
2790 {
2791 Desc: "queryControl on not-an-index",
2792 Path: "/api/index/not-an-index/queryControl/disallow",
2793 Method: "POST",
2794 Params: nil,
2795 Body: nil,
2796 Status: 400,
2797 ResponseMatch: map[string]bool{
2798 `err`: true,
2799 },
2800 },
2801 {
2802 Desc: "create an index with nil feed",
2803 Path: "/api/index/idx0",
2804 Method: "PUT",
2805 Params: url.Values{
2806 "indexType": []string{"fulltext-index"},
2807 "sourceType": []string{"nil"},
2808 },
2809 Body: nil,

Callers

nothing calls this directly

Calls 3

NewRESTRouterFunction · 0.85
testRESTHandlersFunction · 0.85
WriteMethod · 0.45

Tested by

no test coverage detected