(t *testing.T)
| 150 | } |
| 151 | |
| 152 | func 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 | |
| 177 | func TestWatcherStop(t *testing.T) { |
| 178 | tmpDir := t.TempDir() |
nothing calls this directly
no test coverage detected