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

Function TestHandlersWithOnePartitionPrimaryFeedIndex

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

Source from the content-addressed store, hash-verified

878}
879
880func TestHandlersWithOnePartitionPrimaryFeedIndex(t *testing.T) {
881 rest.RequestProxyStubFunc = func() bool {
882 return false
883 }
884 emptyDir, _ := ioutil.TempDir("./tmp", "test")
885 defer func() {
886 os.RemoveAll(emptyDir)
887 rest.RequestProxyStubFunc = nil
888 }()
889
890 cfg := cbgt.NewCfgMem()
891 meh := &TestMEH{}
892 mgr := cbgt.NewManager(cbgt.VERSION, cfg, cbgt.NewUUID(),
893 nil, "", 1, "", ":1000", emptyDir, "some-datasource", meh)
894 mgr.Start("wanted")
895 mgr.Kick("test-start-kick")
896
897 mr, _ := cbgt.NewMsgRing(os.Stderr, 1000)
898
899 router, _, err := NewRESTRouter("v0", mgr, "static", "", mr, nil)
900 if err != nil || router == nil {
901 t.Errorf("no mux router")
902 }
903 var pindex *cbgt.PIndex
904
905 var doneCh chan *httptest.ResponseRecorder
906
907 var feed *cbgt.PrimaryFeed
908
909 tests := []*RESTHandlerTest{
910 {
911 Desc: "create an index with dest feed with bad sourceParams",
912 Path: "/api/index/idx0",
913 Method: "PUT",
914 Params: url.Values{
915 "indexType": []string{"fulltext-index"},
916 "sourceType": []string{"primary"},
917 "sourceParams": []string{"-}totally n0t json{-"},
918 },
919 Body: nil,
920 Status: 400,
921 ResponseMatch: map[string]bool{
922 `could not parse sourceParams`: true,
923 },
924 },
925 {
926 Desc: "create an index with dest feed with 1 partition",
927 Path: "/api/index/idx0",
928 Method: "PUT",
929 Params: url.Values{
930 "indexType": []string{"fulltext-index"},
931 "sourceType": []string{"primary"},
932 "sourceParams": []string{`{"numPartitions":1}`},
933 },
934 Body: nil,
935 Status: http.StatusOK,
936 ResponseMatch: map[string]bool{
937 `"status":"ok"`: true,

Callers

nothing calls this directly

Calls 7

checkMethod · 0.95
NewRESTRouterFunction · 0.85
WaitForPersistenceFunction · 0.85
testRESTHandlersFunction · 0.85
SnapshotStartMethod · 0.80
DataUpdateMethod · 0.80
ServeHTTPMethod · 0.45

Tested by

no test coverage detected