MCPcopy
hub / github.com/MadAppGang/dingo / TestFileWatcher_DetectDingoFileChange

Function TestFileWatcher_DetectDingoFileChange

pkg/lsp/watcher_test.go:10–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestFileWatcher_DetectDingoFileChange(t *testing.T) {
11 tmpDir := t.TempDir()
12 dingoFile := filepath.Join(tmpDir, "test.dingo")
13
14 // Channel to receive file change events
15 changedFiles := make(chan string, 10)
16
17 watcher, err := NewFileWatcher(tmpDir, &testLogger{}, func(path string) {
18 changedFiles <- path
19 })
20 if err != nil {
21 t.Fatalf("Failed to create watcher: %v", err)
22 }
23 defer watcher.Close()
24
25 // Create .dingo file (simulates save)
26 if err := os.WriteFile(dingoFile, []byte("package main\n"), 0644); err != nil {
27 t.Fatalf("Failed to write file: %v", err)
28 }
29
30 // Wait for debounce + processing
31 select {
32 case changed := <-changedFiles:
33 if changed != dingoFile {
34 t.Errorf("Expected %s, got %s", dingoFile, changed)
35 }
36 case <-time.After(1 * time.Second):
37 t.Error("Timeout waiting for file change event")
38 }
39}
40
41func TestFileWatcher_IgnoreNonDingoFiles(t *testing.T) {
42 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 6

CloseMethod · 0.95
NewFileWatcherFunction · 0.85
WriteFileMethod · 0.80
FatalfMethod · 0.65
ErrorfMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected