From 561afb615625f578bcb869930cbb6776edc047a7 Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Thu, 15 Sep 2022 16:43:26 +0200 Subject: [PATCH] Add test for re-adding a renamed file 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 {