(t *testing.T)
| 541 | } |
| 542 | |
| 543 | func TestFeedCommand_CompletedStatus_JSON(t *testing.T) { |
| 544 | resetFeedFlags() |
| 545 | feedFormat = "json" |
| 546 | |
| 547 | oldGitLog := gitLogFunc |
| 548 | gitLogFunc = func(_ string, _ []string) (string, error) { |
| 549 | return sampleGitLogOutput, nil |
| 550 | } |
| 551 | defer func() { gitLogFunc = oldGitLog }() |
| 552 | |
| 553 | oldGitShow := gitShowFunc |
| 554 | gitShowFunc = func(hash, path string) (string, error) { |
| 555 | if strings.Contains(path, "042") { |
| 556 | if strings.HasSuffix(hash, "^") { |
| 557 | return "---\nid: 042\ntitle: Add Auth\nstatus: in-progress\n---\n# Task", nil |
| 558 | } |
| 559 | return "---\nid: 042\ntitle: Add Auth\nstatus: completed\n---\n# Task", nil |
| 560 | } |
| 561 | return "", fmt.Errorf("not found") |
| 562 | } |
| 563 | defer func() { gitShowFunc = oldGitShow }() |
| 564 | |
| 565 | output, err := captureFeedOutput(t, func() error { |
| 566 | return runFeed(feedCmd, nil) |
| 567 | }) |
| 568 | if err != nil { |
| 569 | t.Fatalf("unexpected error: %v", err) |
| 570 | } |
| 571 | |
| 572 | var entries []feed.FeedEntry |
| 573 | if err := json.Unmarshal([]byte(output), &entries); err != nil { |
| 574 | t.Fatalf("failed to parse JSON: %v", err) |
| 575 | } |
| 576 | |
| 577 | // TaskStatus still set for backward compatibility |
| 578 | if entries[0].Files[0].TaskStatus != "completed" { |
| 579 | t.Errorf("expected taskStatus 'completed', got %q", entries[0].Files[0].TaskStatus) |
| 580 | } |
| 581 | |
| 582 | // FieldChanges should include the status transition |
| 583 | if len(entries[0].Files[0].FieldChanges) == 0 { |
| 584 | t.Fatal("expected field changes for task 042") |
| 585 | } |
| 586 | found := false |
| 587 | for _, fc := range entries[0].Files[0].FieldChanges { |
| 588 | if fc.Field == "status" && fc.OldValue == "in-progress" && fc.NewValue == "completed" { |
| 589 | found = true |
| 590 | } |
| 591 | } |
| 592 | if !found { |
| 593 | t.Error("expected status field change in-progress -> completed") |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | func TestBuildGitLogArgs_NoOptionalFlags(t *testing.T) { |
| 598 | args := feed.BuildGitLogArgs("tasks", 20, "", "") |
nothing calls this directly
no test coverage detected