github.com/misseven0/notify@v0.0.0-20230519123055-c1422e46da05/watcher_readdcw_test.go (about) 1 // Copyright (c) 2014-2015 The Notify Authors. All rights reserved. 2 // Use of this source code is governed by the MIT license that can be 3 // found in the LICENSE file. 4 5 //go:build windows 6 // +build windows 7 8 package notify 9 10 import "testing" 11 12 // TODO(ppknap) : remove notify.Create event. 13 func rcreate(w *W, path string) WCase { 14 cas := create(w, path) 15 cas.Events = append(cas.Events, 16 &Call{P: path, E: FileActionAdded}, 17 ) 18 return cas 19 } 20 21 // TODO(ppknap) : remove notify.Remove event. 22 func rremove(w *W, path string) WCase { 23 cas := remove(w, path) 24 cas.Events = append(cas.Events, 25 &Call{P: path, E: FileActionRemoved}, 26 ) 27 return cas 28 } 29 30 // TODO(ppknap) : remove notify.Rename event. 31 func rrename(w *W, oldpath, newpath string) WCase { 32 cas := rename(w, oldpath, newpath) 33 cas.Events = append(cas.Events, 34 &Call{P: oldpath, E: FileActionRenamedOldName}, 35 &Call{P: newpath, E: FileActionRenamedNewName}, 36 ) 37 return cas 38 } 39 40 // TODO(ppknap) : remove notify.Write event. 41 func rwrite(w *W, path string, p []byte) WCase { 42 cas := write(w, path, p) 43 cas.Events = append(cas.Events, 44 &Call{P: path, E: FileActionModified}, 45 ) 46 return cas 47 } 48 49 var events = []Event{ 50 FileNotifyChangeFileName, 51 FileNotifyChangeDirName, 52 FileNotifyChangeSize, 53 } 54 55 func TestWatcherReadDirectoryChangesW(t *testing.T) { 56 w := NewWatcherTest(t, "testdata/vfs.txt", events...) 57 defer w.Close() 58 59 cases := [...]WCase{ 60 rcreate(w, "src/github.com/rjeczalik/fs/fs_windows.go"), 61 rcreate(w, "src/github.com/rjeczalik/fs/subdir/"), 62 rremove(w, "src/github.com/rjeczalik/fs/fs.go"), 63 rrename(w, "src/github.com/rjeczalik/fs/LICENSE", "src/github.com/rjeczalik/fs/COPYLEFT"), 64 rwrite(w, "src/github.com/rjeczalik/fs/cmd/gotree/go.go", []byte("XD")), 65 } 66 67 w.ExpectAny(cases[:]) 68 }