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

Function TestDataProvider_Invalidate

apps/cli/internal/web/data_provider_test.go:44–85  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestDataProvider_Invalidate(t *testing.T) {
45 dir := createTestTaskDir(t)
46 dp := NewDataProvider(dir, false)
47
48 // Initial scan
49 tasks1, err := dp.GetTasks()
50 if err != nil {
51 t.Fatalf("unexpected error: %v", err)
52 }
53 if len(tasks1) != 2 {
54 t.Fatalf("expected 2 tasks, got %d", len(tasks1))
55 }
56
57 // Add a new task file
58 task3 := `---
59id: "003"
60title: "Task Three"
61status: pending
62---
63# Task Three
64`
65 os.WriteFile(filepath.Join(dir, "003-task-three.md"), []byte(task3), 0644)
66
67 // Without invalidation, should still return cached 2 tasks
68 tasks2, err := dp.GetTasks()
69 if err != nil {
70 t.Fatalf("unexpected error: %v", err)
71 }
72 if len(tasks2) != 2 {
73 t.Fatalf("expected 2 cached tasks, got %d", len(tasks2))
74 }
75
76 // After invalidation, should re-scan and find 3 tasks
77 dp.Invalidate()
78 tasks3, err := dp.GetTasks()
79 if err != nil {
80 t.Fatalf("unexpected error: %v", err)
81 }
82 if len(tasks3) != 3 {
83 t.Fatalf("expected 3 tasks after invalidation, got %d", len(tasks3))
84 }
85}

Callers

nothing calls this directly

Calls 4

GetTasksMethod · 0.95
InvalidateMethod · 0.95
createTestTaskDirFunction · 0.85
NewDataProviderFunction · 0.85

Tested by

no test coverage detected