(t *testing.T)
| 162 | } |
| 163 | |
| 164 | func TestFeedCommand_JSON(t *testing.T) { |
| 165 | resetFeedFlags() |
| 166 | feedFormat = "json" |
| 167 | |
| 168 | oldGitLog := gitLogFunc |
| 169 | gitLogFunc = func(_ string, _ []string) (string, error) { |
| 170 | return sampleGitLogOutput, nil |
| 171 | } |
| 172 | defer func() { gitLogFunc = oldGitLog }() |
| 173 | |
| 174 | oldGitShow := gitShowFunc |
| 175 | gitShowFunc = noopGitShow |
| 176 | defer func() { gitShowFunc = oldGitShow }() |
| 177 | |
| 178 | output, err := captureFeedOutput(t, func() error { |
| 179 | return runFeed(feedCmd, nil) |
| 180 | }) |
| 181 | if err != nil { |
| 182 | t.Fatalf("unexpected error: %v", err) |
| 183 | } |
| 184 | |
| 185 | var entries []feed.FeedEntry |
| 186 | if err := json.Unmarshal([]byte(output), &entries); err != nil { |
| 187 | t.Fatalf("failed to parse JSON: %v\noutput: %s", err, output) |
| 188 | } |
| 189 | |
| 190 | if len(entries) != 2 { |
| 191 | t.Errorf("expected 2 entries, got %d", len(entries)) |
| 192 | } |
| 193 | if entries[0].Author != "Alice" { |
| 194 | t.Errorf("expected Alice, got %s", entries[0].Author) |
| 195 | } |
| 196 | if len(entries[1].Files) != 2 { |
| 197 | t.Errorf("expected 2 files in second entry, got %d", len(entries[1].Files)) |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | func TestFeedCommand_Limit(t *testing.T) { |
| 202 | resetFeedFlags() |
nothing calls this directly
no test coverage detected