micro/registry/memory/watcher_test.go

36 lines
543 B
Go
Raw Normal View History

2019-01-18 17:29:17 +00:00
package memory
import (
"testing"
"github.com/micro/go-micro/v3/registry"
2019-01-18 17:29:17 +00:00
)
func TestWatcher(t *testing.T) {
w := &Watcher{
id: "test",
res: make(chan *registry.Result),
exit: make(chan bool),
wo: registry.WatchOptions{
Domain: registry.WildcardDomain,
},
2019-01-18 17:29:17 +00:00
}
go func() {
w.res <- &registry.Result{
Service: &registry.Service{Name: "foo"},
}
2019-01-18 17:29:17 +00:00
}()
_, err := w.Next()
if err != nil {
t.Fatal("unexpected err", err)
}
w.Stop()
if _, err := w.Next(); err == nil {
t.Fatal("expected error on Next()")
}
}