(t *testing.T)
| 3074 | } |
| 3075 | |
| 3076 | func TestIndexDefWithJSON(t *testing.T) { |
| 3077 | rest.RequestProxyStubFunc = func() bool { |
| 3078 | return false |
| 3079 | } |
| 3080 | emptyDir, _ := ioutil.TempDir("./tmp", "test") |
| 3081 | defer func() { |
| 3082 | os.RemoveAll(emptyDir) |
| 3083 | rest.RequestProxyStubFunc = nil |
| 3084 | }() |
| 3085 | |
| 3086 | cfg := cbgt.NewCfgMem() |
| 3087 | meh := &TestMEH{} |
| 3088 | mgr := cbgt.NewManager(cbgt.VERSION, cfg, cbgt.NewUUID(), |
| 3089 | nil, "", 1, "", ":1000", emptyDir, "some-datasource", meh) |
| 3090 | mgr.Start("wanted") |
| 3091 | mgr.Kick("test-start-kick") |
| 3092 | |
| 3093 | mr, _ := cbgt.NewMsgRing(os.Stderr, 1000) |
| 3094 | mr.Write([]byte("hello")) |
| 3095 | mr.Write([]byte("world")) |
| 3096 | |
| 3097 | router, _, err := NewRESTRouter("v0", mgr, "static", "", mr, nil) |
| 3098 | if err != nil || router == nil { |
| 3099 | t.Errorf("no mux router") |
| 3100 | } |
| 3101 | |
| 3102 | tests := []*RESTHandlerTest{ |
| 3103 | { |
| 3104 | Desc: "try create index with bad JSON", |
| 3105 | Path: "/api/index/idx0", |
| 3106 | Method: "PUT", |
| 3107 | Params: url.Values{ |
| 3108 | "indexType": []string{"fulltext-index"}, |
| 3109 | "sourceType": []string{"primary"}, |
| 3110 | "sourceParams": []string{`{"numPartitions":10}`}, |
| 3111 | }, |
| 3112 | Body: []byte(`BAAAAD json! :-{`), |
| 3113 | Status: 400, |
| 3114 | ResponseMatch: map[string]bool{ |
| 3115 | `err`: true, |
| 3116 | }, |
| 3117 | }, |
| 3118 | { |
| 3119 | Desc: "create index with primary feed", |
| 3120 | Path: "/api/index/idx0", |
| 3121 | Method: "PUT", |
| 3122 | Params: url.Values{ |
| 3123 | "indexType": []string{"fulltext-index"}, |
| 3124 | "sourceType": []string{"primary"}, |
| 3125 | "sourceParams": []string{`{"numPartitions":10}`}, |
| 3126 | }, |
| 3127 | Body: []byte(`{ "indexType": "fulltext-index", |
| 3128 | "indexParams": "{}", |
| 3129 | "sourceType": "primary", |
| 3130 | "sourceUUID": "beefbeef", |
| 3131 | "sourceParams": "{\"numPartitions\":10}" |
| 3132 | }`), |
| 3133 | Status: http.StatusOK, |
nothing calls this directly
no test coverage detected