watcher_test.go 388 B

12345678910111213141516171819202122232425262728
  1. package main
  2. import (
  3. "testing"
  4. "fmt"
  5. )
  6. func TestWatch(t *testing.T) {
  7. // watcher := createWatcher()
  8. c := make(chan Notification)
  9. d := make(chan Notification)
  10. w.add("/", c)
  11. go say(c)
  12. w.add("/prefix/", d)
  13. go say(d)
  14. s.Set("/prefix/foo", "bar")
  15. }
  16. func say(c chan Notification) {
  17. result := <-c
  18. if result.action != -1 {
  19. fmt.Println("yes")
  20. } else {
  21. fmt.Println("no")
  22. }
  23. }