MCPcopy Create free account
hub / github.com/dropbox/dbxcli / TestSearchJSONOmitsPathWithoutScope

Function TestSearchJSONOmitsPathWithoutScope

cmd/search_test.go:278–317  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

276}
277
278func TestSearchJSONOmitsPathWithoutScope(t *testing.T) {
279 cmd, stdout := testSearchCmd()
280 setSearchOutputJSON(t, cmd)
281
282 mock := &mockFilesClient{
283 searchV2Fn: func(arg *files.SearchV2Arg) (*files.SearchV2Result, error) {
284 if arg.Options == nil {
285 t.Fatal("options = nil, want search options")
286 }
287 if arg.Options.Path != "" {
288 t.Fatalf("options path = %q, want empty", arg.Options.Path)
289 }
290 if !arg.Options.FilenameOnly {
291 t.Fatal("filename_only = false, want true by default")
292 }
293 return files.NewSearchV2Result(nil, false), nil
294 },
295 }
296 stubFilesClient(t, mock)
297
298 if err := search(cmd, []string{"report"}); err != nil {
299 t.Fatalf("search error: %v", err)
300 }
301 output := append([]byte(nil), stdout.Bytes()...)
302 got := decodeSearchOutput(t, stdout)
303 if got.Input.Query != "report" || got.Input.Path != "" {
304 t.Fatalf("input = %#v, want query report and empty path", got.Input)
305 }
306 var raw map[string]any
307 if err := json.Unmarshal(output, &raw); err != nil {
308 t.Fatalf("decode raw JSON output: %v\noutput: %s", err, string(output))
309 }
310 input, ok := raw["input"].(map[string]any)
311 if !ok {
312 t.Fatalf("raw input = %#v, want object", raw["input"])
313 }
314 if _, ok := input["path"]; ok {
315 t.Fatalf("input path key is present in %s, want omitted", string(output))
316 }
317}
318
319func TestSearchLimitCapsResultsAndStopsPagination(t *testing.T) {
320 cmd, stdout := testSearchCmd()

Callers

nothing calls this directly

Calls 5

testSearchCmdFunction · 0.85
setSearchOutputJSONFunction · 0.85
stubFilesClientFunction · 0.85
searchFunction · 0.85
decodeSearchOutputFunction · 0.85

Tested by

no test coverage detected