From 98c890aec17d6d2cf2168c1ac1de16b294c78b25 Mon Sep 17 00:00:00 2001 From: Benjamin Radovsky Date: Thu, 15 Jun 2017 20:46:14 +1000 Subject: [PATCH] added some small tests --- watcher_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/watcher_test.go b/watcher_test.go index ac17379..02c232c 100644 --- a/watcher_test.go +++ b/watcher_test.go @@ -229,6 +229,15 @@ func TestIgnore(t *testing.T) { if len(w.files) != 0 { t.Errorf("expected len(w.files) to be 0, got %d", len(w.files)) } + + // Now try to add the ignored directory. + err = w.Add(testDir) + if err != nil { + t.Errorf("expected error to be nil, got %s", err) + } + if len(w.files) != 0 { + t.Errorf("expected len(w.files) to be 0, got %d", len(w.files)) + } } func TestRemove(t *testing.T) { @@ -477,6 +486,15 @@ func TestListFiles(t *testing.T) { t.Errorf("expected fileList[%s].Name() to be file.txt, got %s", fname, fileList[fname].Name()) } + + // Try to call list on a file that's not a directory. + fileList, err := w.list(fname) + if err != nil { + t.Error("expected err to be nil") + } + if len(fileList) != 1 { + t.Errorf("expected len of file list to be 1, got %d", len(fileList)) + } } func TestTriggerEvent(t *testing.T) {