From 89b4cf13a78441b79b86eeea2ff309bf95bdbf66 Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Thu, 15 Sep 2022 18:42:57 +0200 Subject: [PATCH] Add test for re-adding a renamed file (#508) Ref: #503 --- fsnotify_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/fsnotify_test.go b/fsnotify_test.go index be093ec0..d8c7f5e2 100644 --- a/fsnotify_test.go +++ b/fsnotify_test.go @@ -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 {