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

Function TestSearch_JSONFormat

apps/cli/internal/cli/search_test.go:224–256  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

222}
223
224func TestSearch_JSONFormat(t *testing.T) {
225 resetSearchFlags()
226
227 tasks := []*model.Task{
228 {ID: "001", Title: "Auth system", Status: model.StatusPending, Priority: model.PriorityHigh, FilePath: "tasks/001.md", Body: "JWT authentication"},
229 }
230
231 output, err := captureSearchOutput(t, tasks, "authentication", "json")
232 if err != nil {
233 t.Fatalf("unexpected error: %v", err)
234 }
235
236 var parsed []search.Result
237 if err := json.Unmarshal([]byte(output), &parsed); err != nil {
238 t.Fatalf("failed to parse JSON output: %v\noutput: %s", err, output)
239 }
240
241 if len(parsed) != 1 {
242 t.Fatalf("expected 1 result in JSON, got %d", len(parsed))
243 }
244 if parsed[0].ID != "001" {
245 t.Errorf("expected id '001', got %s", parsed[0].ID)
246 }
247 if parsed[0].MatchLocation != "body" {
248 t.Errorf("expected match_location 'body', got %s", parsed[0].MatchLocation)
249 }
250 if parsed[0].Snippet == "" {
251 t.Error("expected non-empty snippet")
252 }
253 if parsed[0].Priority != "high" {
254 t.Errorf("expected priority 'high', got %s", parsed[0].Priority)
255 }
256}
257
258func TestSearch_YAMLFormat(t *testing.T) {
259 resetSearchFlags()

Callers

nothing calls this directly

Calls 3

resetSearchFlagsFunction · 0.85
captureSearchOutputFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected