MCPcopy Create free account
hub / github.com/celer-pkg/celer / TestSearchCmd_Completion_ErrorHandling

Function TestSearchCmd_Completion_ErrorHandling

cmds/cmd_search_test.go:396–427  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

394}
395
396func 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
429func TestSearchCmd_DoSearch_Integration(t *testing.T) {
430 // Cleanup.

Callers

nothing calls this directly

Calls 6

InitMethod · 0.95
CommandMethod · 0.95
completionMethod · 0.95
RemoveAllForTestFunction · 0.92
NewCelerFunction · 0.92
checkFunction · 0.85

Tested by

no test coverage detected