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

Function TestWatcher_DetectsChanges

apps/cli/internal/watcher/watcher_test.go:11–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestWatcher_DetectsChanges(t *testing.T) {
12 dir := t.TempDir()
13
14 // Create initial file
15 initial := filepath.Join(dir, "task.md")
16 os.WriteFile(initial, []byte("# initial"), 0644)
17
18 var count atomic.Int32
19 w := New(dir, func() {
20 count.Add(1)
21 }, 50*time.Millisecond)
22
23 go func() {
24 if err := w.Start(); err != nil {
25 t.Logf("watcher error: %v", err)
26 }
27 }()
28
29 // Wait for watcher to initialize
30 time.Sleep(100 * time.Millisecond)
31
32 // Modify the file
33 os.WriteFile(initial, []byte("# modified"), 0644)
34
35 // Wait for debounce
36 time.Sleep(200 * time.Millisecond)
37
38 w.Stop()
39
40 if count.Load() < 1 {
41 t.Fatal("expected onChange to be called at least once")
42 }
43}
44
45func TestWatcher_IgnoresNonMarkdown(t *testing.T) {
46 dir := t.TempDir()

Callers

nothing calls this directly

Calls 3

NewFunction · 0.85
StopMethod · 0.80
StartMethod · 0.45

Tested by

no test coverage detected