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

Function TestFeedCommand_JSON

apps/cli/internal/cli/feed_test.go:164–199  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

162}
163
164func 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
201func TestFeedCommand_Limit(t *testing.T) {
202 resetFeedFlags()

Callers

nothing calls this directly

Calls 3

resetFeedFlagsFunction · 0.85
captureFeedOutputFunction · 0.85
runFeedFunction · 0.85

Tested by

no test coverage detected