Skip to content

Commit

Permalink
added some small tests
Browse files Browse the repository at this point in the history
  • Loading branch information
radovskyb committed Jun 15, 2017
1 parent bbc1ad0 commit 98c890a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 98c890a

Please sign in to comment.