(t *testing.T)
| 516 | } |
| 517 | |
| 518 | func 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 | |
| 558 | func TestNext_YAMLFormat(t *testing.T) { |
| 559 | tmpDir := createNextTestTaskFiles(t) |
nothing calls this directly
no test coverage detected