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

Function TestNext_JSONFormat

apps/cli/internal/cli/next_test.go:518–556  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

516}
517
518func TestNext_JSONFormat(t *testing.T) {
519 tmpDir := createNextTestTaskFiles(t)
520
521 resetNextFlags()
522 nextFormat = "json"
523 nextLimit = 2
524
525 output, err := captureNextOutput(t, []string{tmpDir})
526 if err != nil {
527 t.Fatalf("runNext failed: %v", err)
528 }
529
530 var recs []Recommendation
531 if err := json.Unmarshal([]byte(output), &recs); err != nil {
532 t.Fatalf("Failed to parse JSON output: %v\nOutput: %s", err, output)
533 }
534
535 if len(recs) != 2 {
536 t.Fatalf("Expected 2 recommendations, got %d", len(recs))
537 }
538
539 // Verify all fields are present
540 rec := recs[0]
541 if rec.Rank != 1 {
542 t.Errorf("Expected rank=1, got %d", rec.Rank)
543 }
544 if rec.ID == "" {
545 t.Error("Expected non-empty ID")
546 }
547 if rec.Title == "" {
548 t.Error("Expected non-empty Title")
549 }
550 if rec.Score <= 0 {
551 t.Errorf("Expected positive score, got %d", rec.Score)
552 }
553 if len(rec.Reasons) == 0 {
554 t.Error("Expected at least one reason")
555 }
556}
557
558func TestNext_YAMLFormat(t *testing.T) {
559 tmpDir := createNextTestTaskFiles(t)

Callers

nothing calls this directly

Calls 4

createNextTestTaskFilesFunction · 0.85
resetNextFlagsFunction · 0.85
captureNextOutputFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected