From 9fd2f9eabe93713c0e8fb7dd094e77109db84265 Mon Sep 17 00:00:00 2001 From: RanXom Date: Tue, 14 Jul 2026 11:46:12 +0530 Subject: feat(watcher): introduce filesystem watcher abstraction --- internal/watcher/watcher_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 internal/watcher/watcher_test.go (limited to 'internal/watcher/watcher_test.go') diff --git a/internal/watcher/watcher_test.go b/internal/watcher/watcher_test.go new file mode 100644 index 0000000..53c0baa --- /dev/null +++ b/internal/watcher/watcher_test.go @@ -0,0 +1,31 @@ +package watcher + +import ( + "context" + "testing" + "time" +) + +func TestRunReturnsOnContextCancellation(t *testing.T) { + w := New(Config{}) + + ctx, cancel := context.WithCancel(context.Background()) + + done := make(chan error, 1) + + go func() { + done <- w.Run(ctx) + }() + + cancel() + + select { + case err := <-done: + if err != nil { + t.Fatalf("expected nil, got %v", err) + } + + case <-time.After(time.Second): + t.Fatal("watcher did not exit") + } +} -- cgit v1.2.3