| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
package notify |
| 8 |
|
| 9 |
import "testing" |
| 10 |
|
| 11 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
} |