MCPcopy Create free account
hub / github.com/MiniCodeMonkey/chief / TestWatcherHandlesFileNotFound

Function TestWatcherHandlesFileNotFound

internal/prd/watcher_test.go:152–175  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

150}
151
152func TestWatcherHandlesFileNotFound(t *testing.T) {
153 tmpDir := t.TempDir()
154 prdPath := filepath.Join(tmpDir, "nonexistent.md")
155
156 watcher, err := NewWatcher(prdPath)
157 if err != nil {
158 t.Fatalf("Failed to create watcher: %v", err)
159 }
160 defer watcher.Stop()
161
162 if err := watcher.Start(); err != nil {
163 t.Logf("Got expected start error: %v", err)
164 return
165 }
166
167 select {
168 case event := <-watcher.Events():
169 if event.Error == nil {
170 t.Error("Expected error event for nonexistent file")
171 }
172 case <-time.After(1 * time.Second):
173 t.Log("No error event received, which is acceptable if Add failed")
174 }
175}
176
177func TestWatcherStop(t *testing.T) {
178 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 4

StopMethod · 0.95
StartMethod · 0.95
EventsMethod · 0.95
NewWatcherFunction · 0.85

Tested by

no test coverage detected