watcher_test.go 401 B

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