watcher_test.go 404 B

1234567891011121314151617181920212223242526
  1. package raftd
  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. watcher.add("/", c, say)
  11. watcher.add("/prefix/", d, say)
  12. watcher.notify(0, "/prefix/hihihi", "1", "1")
  13. }
  14. func say(c chan Notification) {
  15. result := <-c
  16. if result.action != -1 {
  17. fmt.Println("yes")
  18. } else {
  19. fmt.Println("no")
  20. }
  21. }