]> go.fuhry.dev Git - fsnotify.git/commitdiff
Add test for re-adding a renamed file (#508)
authorMartin Tournoij <martin@arp242.net>
Thu, 15 Sep 2022 16:42:57 +0000 (18:42 +0200)
committerGitHub <noreply@github.com>
Thu, 15 Sep 2022 16:42:57 +0000 (18:42 +0200)
Ref: #503

fsnotify_test.go

index be093ec0c885352f082996692f852f87013c79c6..d8c7f5e2aaad6df22b00e734bc58e0a2347f93ed 100644 (file)
@@ -492,6 +492,35 @@ func TestWatchRename(t *testing.T) {
                                rename     /file
                                rename     /rename-one
                `},
+
+               {"re-add renamed file", func(t *testing.T, w *Watcher, tmp string) {
+                       file := filepath.Join(tmp, "file")
+                       rename := filepath.Join(tmp, "rename")
+                       touch(t, file)
+
+                       addWatch(t, w, file)
+
+                       mv(t, file, rename)
+                       touch(t, file)
+                       addWatch(t, w, file)
+                       cat(t, "hello", rename)
+                       cat(t, "hello", file)
+               }, `
+                       rename /file    # mv file rename
+                       write  /rename  # cat hello >rename
+                       write  /file    # cat hello >file
+
+                       # TODO: wrong.
+                       linux:
+                           RENAME     "/file"
+                           WRITE      "/file"
+                           WRITE      ""
+
+                       # TODO: wrong.
+                       kqueue:
+                          RENAME      "/file"
+                          WRITE       "/file"
+               `},
        }
 
        for _, tt := range tests {