MCPcopy Create free account
hub / github.com/driangle/taskmd / TestSearch_SortByPriority

Function TestSearch_SortByPriority

apps/cli/internal/cli/search_test.go:455–482  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

453}
454
455func TestSearch_SortByPriority(t *testing.T) {
456 resetSearchFlags()
457
458 tasks := []*model.Task{
459 {ID: "001", Title: "Deploy low", Status: model.StatusPending, Priority: model.PriorityLow, Body: "deploy staging"},
460 {ID: "002", Title: "Deploy critical", Status: model.StatusPending, Priority: model.PriorityCritical, Body: "deploy production"},
461 {ID: "003", Title: "Deploy high", Status: model.StatusPending, Priority: model.PriorityHigh, Body: "deploy canary"},
462 }
463
464 if err := sortTasks(tasks, "priority"); err != nil {
465 t.Fatalf("unexpected sort error: %v", err)
466 }
467 results := search.Search(tasks, "deploy")
468
469 if len(results) != 3 {
470 t.Fatalf("expected 3 results, got %d", len(results))
471 }
472 // Critical first, then high, then low
473 if results[0].ID != "002" {
474 t.Errorf("expected first result to be 002 (critical), got %s", results[0].ID)
475 }
476 if results[1].ID != "003" {
477 t.Errorf("expected second result to be 003 (high), got %s", results[1].ID)
478 }
479 if results[2].ID != "001" {
480 t.Errorf("expected third result to be 001 (low), got %s", results[2].ID)
481 }
482}
483
484func TestSearch_LimitResults(t *testing.T) {
485 resetSearchFlags()

Callers

nothing calls this directly

Calls 2

resetSearchFlagsFunction · 0.85
sortTasksFunction · 0.70

Tested by

no test coverage detected