MCPcopy Create free account
hub / github.com/NV404/gova / TestWatcherFiresOnGoFileWrite

Function TestWatcherFiresOnGoFileWrite

internal/devserver/watcher_test.go:30–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28const eventWait = 3 * time.Second
29
30func TestWatcherFiresOnGoFileWrite(t *testing.T) {
31 dir := t.TempDir()
32 w, err := NewWatcher(WatcherOptions{Root: dir, Debounce: 30 * time.Millisecond})
33 if err != nil {
34 t.Fatalf("NewWatcher: %v", err)
35 }
36 defer w.Close()
37 time.Sleep(watcherWarmup)
38
39 // Writing a fresh .go file in the watched dir fires a Create, which is
40 // delivered reliably on both inotify and kqueue. Seed-then-modify races
41 // with kqueue's file-level watch registration on macOS CI.
42 if err := os.WriteFile(filepath.Join(dir, "main.go"), []byte("package x\n"), 0o644); err != nil {
43 t.Fatalf("write: %v", err)
44 }
45 if !waitEvent(t, w.Events(), eventWait) {
46 t.Fatal("expected debounced event after .go write")
47 }
48}
49
50func TestWatcherIgnoresNonGoFiles(t *testing.T) {
51 dir := t.TempDir()

Callers

nothing calls this directly

Calls 4

CloseMethod · 0.95
EventsMethod · 0.95
NewWatcherFunction · 0.85
waitEventFunction · 0.85

Tested by

no test coverage detected