aboutsummaryrefslogtreecommitdiff
path: root/internal/watcher/watcher_test.go
diff options
context:
space:
mode:
authorRanXom <saiyedshizain@gmail.com>2026-07-14 11:46:12 +0530
committerRanXom <saiyedshizain@gmail.com>2026-07-14 11:46:12 +0530
commit9fd2f9eabe93713c0e8fb7dd094e77109db84265 (patch)
tree7d94561ae0a3bb8f54b52cd7c6b15387a9f640fc /internal/watcher/watcher_test.go
parented87aebc0296379280fd65d618127b4eeb848a98 (diff)
downloadgalleryd-9fd2f9eabe93713c0e8fb7dd094e77109db84265.tar.xz
galleryd-9fd2f9eabe93713c0e8fb7dd094e77109db84265.zip
feat(watcher): introduce filesystem watcher abstraction
Diffstat (limited to 'internal/watcher/watcher_test.go')
-rw-r--r--internal/watcher/watcher_test.go31
1 files changed, 31 insertions, 0 deletions
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")
+ }
+}