(t *testing.T)
| 361 | } |
| 362 | |
| 363 | func TestSearchJSONErrorWritesNoOutput(t *testing.T) { |
| 364 | cmd, stdout := testSearchCmd() |
| 365 | setSearchOutputJSON(t, cmd) |
| 366 | |
| 367 | mock := &mockFilesClient{ |
| 368 | searchV2Fn: func(arg *files.SearchV2Arg) (*files.SearchV2Result, error) { |
| 369 | return nil, fmt.Errorf("search failed") |
| 370 | }, |
| 371 | } |
| 372 | stubFilesClient(t, mock) |
| 373 | |
| 374 | if err := search(cmd, []string{"report"}); err == nil { |
| 375 | t.Fatal("expected search error") |
| 376 | } |
| 377 | if got := stdout.String(); got != "" { |
| 378 | t.Fatalf("stdout = %q, want empty output on error", got) |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | func TestSearchCommandSupportsStructuredOutput(t *testing.T) { |
| 383 | if !commandSupportsStructuredOutput(searchCmd) { |
nothing calls this directly
no test coverage detected