watcher_test.go 401 B

12345678910111213141516171819202122232425262728293031
  1. package fileSystem
  2. import (
  3. "testing"
  4. )
  5. func TestWatch(t *testing.T) {
  6. wh := newWatchHub(100)
  7. err, c := wh.watch("/foo", 0)
  8. if err != nil {
  9. t.Fatal("%v", err)
  10. }
  11. select {
  12. case <-c:
  13. t.Fatal("should not receive from channel before send the event")
  14. default:
  15. // do nothing
  16. }
  17. e := newEvent(Set, "/foo/bar", 1, 0)
  18. wh.notify(e)
  19. re := <-c
  20. if e != re {
  21. t.Fatal("recv != send")
  22. }
  23. }