add tests for fswatcher package

This commit is contained in:
Dominic Breuker committed 2018-03-12 08:58:01 +01:00
1 parent d38cb18712
commit a2dfb51d51
14 files changed
+277 -199

No files matched your search

+7 -1
View File
@@ -7,9 +7,15 @@ import (
"path/filepath"
)
type Walker struct{}
func NewWalker() *Walker {
return &Walker{}
}
const maxInt = int(^uint(0) >> 1)
func Walk(root string, depth int) (dirCh chan string, errCh chan error, doneCh chan struct{}) {
func (w *Walker) Walk(root string, depth int) (dirCh chan string, errCh chan error, doneCh chan struct{}) {
if depth < 0 {
depth = maxInt
}
+2 -1
View File
@@ -39,7 +39,8 @@ func TestWalk(t *testing.T) {
}
for i, tt := range tests {
dirCh, errCh, doneCh := Walk(tt.root, tt.depth)
w := &Walker{}
dirCh, errCh, doneCh := w.Walk(tt.root, tt.depth)
dirs, errs := getAllDirsAndErrors(dirCh, errCh)
if !reflect.DeepEqual(dirs, tt.result) {