github.com/Hellyna/notify@v0.0.0-20210101060149-8ebdd4ef22cf/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 // +build windows 6 7 package notify 8 9 import "testing" 10 11 // TODO(ppknap) : remove notify.Create event. 12 func rcreate(w *W, path string) WCase { 13 cas := create(w, path) 14 cas.Events = append(cas.Events, 15 &Call{P: path, E: FileActionAdded}, 16 ) 17 return cas 18 } 19 20 // TODO(ppknap) : remove notify.Remove event. 21 func rremove(w *W, path string) WCase { 22 cas := remove(w, path) 23 cas.Events = append(cas.Events, 24 &Call{P: path, E: FileActionRemoved}, 25 ) 26 return cas 27 } 28 29 // TODO(ppknap) : remove notify.Rename event. 30 func rrename(w *W, oldpath, newpath string) WCase { 31 cas := rename(w, oldpath, newpath) 32 cas.Events = append(cas.Events, 33 &Call{P: oldpath, E: FileActionRenamedOldName}, 34 &Call{P: newpath, E: FileActionRenamedNewName}, 35 ) 36 return cas 37 } 38 39 // TODO(ppknap) : remove notify.Write event. 40 func rwrite(w *W, path string, p []byte) WCase { 41 cas := write(w, path, p) 42 cas.Events = append(cas.Events, 43 &Call{P: path, E: FileActionModified}, 44 ) 45 return cas 46 } 47 48 var events = []Event{ 49 FileNotifyChangeFileName, 50 FileNotifyChangeDirName, 51 FileNotifyChangeSize, 52 } 53 54 func TestWatcherReadDirectoryChangesW(t *testing.T) { 55 w := NewWatcherTest(t, "testdata/vfs.txt", events...) 56 defer w.Close() 57 58 cases := [...]WCase{ 59 rcreate(w, "src/github.com/rjeczalik/fs/fs_windows.go"), 60 rcreate(w, "src/github.com/rjeczalik/fs/subdir/"), 61 rremove(w, "src/github.com/rjeczalik/fs/fs.go"), 62 rrename(w, "src/github.com/rjeczalik/fs/LICENSE", "src/github.com/rjeczalik/fs/COPYLEFT"), 63 rwrite(w, "src/github.com/rjeczalik/fs/cmd/gotree/go.go", []byte("XD")), 64 } 65 66 w.ExpectAny(cases[:]) 67 }