Skip to content

Commit

Permalink
readdcw: add tests for system-dependent events
Browse files Browse the repository at this point in the history
  • Loading branch information
Pawel Knap committed Feb 13, 2015
1 parent 721cfe0 commit b504320
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
25 changes: 25 additions & 0 deletions notify_readdcw_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// +build windows

package notify

import "testing"

func TestNotifySystemAndGlobalMix(t *testing.T) {
t.Skip("TODO(ppknap)")
n := NewNotifyTest(t, "testdata/vfs.txt")
defer n.Close()

ch := NewChans(2)

n.Watch("src/github.com/rjeczalik/fs", ch[0], Create)
n.Watch("src/github.com/rjeczalik/fs", ch[1], FileActionAdded)

cases := []NCase{
{
Event: rcreate(n.W(), "src/github.com/rjeczalik/fs/.main.cc.swr"),
Receiver: Chans{ch[0], ch[1]},
},
}

n.ExpectNotifyEvents(cases, ch)
}
1 change: 0 additions & 1 deletion watcher_inotify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

func icreate(w *W, path string) WCase {
cas := create(w, path)
path = cas.Events[0].Path()
cas.Events = append(cas.Events,
&Call{P: path, E: InCreate},
)
Expand Down
52 changes: 52 additions & 0 deletions watcher_readdcw_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// +build windows

package notify

import "testing"

// rcreate TODO
func rcreate(w *W, path string) WCase {
cas := create(w, path)
cas.Events = append(cas.Events,
&Call{P: path, E: FileActionAdded},
)
return cas
}

// rremove TODO
func rremove(w *W, path string) WCase {
cas := remove(w, path)
cas.Events = append(cas.Events,
&Call{P: path, E: FileActionRemoved},
)
return cas
}

// rrename TODO
func rrename(w *W, oldpath, newpath string) WCase {
cas := rename(w, oldpath, newpath)
cas.Events = append(cas.Events,
&Call{P: oldpath, E: FileActionRenamedOldName},
&Call{P: newpath, E: FileActionRenamedNewName},
)
return cas
}

var events = []Event{
FileNotifyChangeFileName,
FileNotifyChangeDirName,
}

func TestWatcherReadDirectoryChangesW(t *testing.T) {
w := NewWatcherTest(t, "testdata/vfs.txt", events...)
defer w.Close()

cases := [...]WCase{
rcreate(w, "src/github.com/rjeczalik/fs/fs_windows.go"),
rcreate(w, "src/github.com/rjeczalik/fs/subdir/"),
rremove(w, "src/github.com/rjeczalik/fs/fs.go"),
rrename(w, "src/github.com/rjeczalik/fs/LICENSE", "src/github.com/rjeczalik/fs/COPYLEFT"),
}

w.ExpectAny(cases[:])
}

0 comments on commit b504320

Please sign in to comment.