(t *testing.T)
| 394 | } |
| 395 | |
| 396 | func TestSearchCmd_Completion_ErrorHandling(t *testing.T) { |
| 397 | // Cleanup. |
| 398 | dirs.RemoveAllForTest() |
| 399 | |
| 400 | // Check error. |
| 401 | var check = func(err error) { |
| 402 | t.Helper() |
| 403 | if err != nil { |
| 404 | t.Fatal(err) |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | // Init celer without setup (ports dir may not exist). |
| 409 | celer := configs.NewCeler() |
| 410 | check(celer.Init()) |
| 411 | |
| 412 | searchCmd := searchCmd{celer: celer} |
| 413 | cmd := searchCmd.Command(celer) |
| 414 | |
| 415 | // Test completion when ports directory doesn't exist. |
| 416 | suggestions, directive := searchCmd.completion(cmd, []string{}, "test") |
| 417 | |
| 418 | // Should not panic and should return valid directive. |
| 419 | if directive != cobra.ShellCompDirectiveNoFileComp { |
| 420 | t.Errorf("Expected directive NoFileComp, got %v", directive) |
| 421 | } |
| 422 | |
| 423 | // Should return empty suggestions or handle gracefully. |
| 424 | if len(suggestions) > 0 { |
| 425 | t.Log("Got some suggestions despite missing ports dir (acceptable)") |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | func TestSearchCmd_DoSearch_Integration(t *testing.T) { |
| 430 | // Cleanup. |
nothing calls this directly
no test coverage detected