2019-01-18 20:29:17 +03:00
|
|
|
package memory
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-01-30 14:39:00 +03:00
|
|
|
"github.com/micro/go-micro/v2/registry"
|
2019-01-18 20:29:17 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestWatcher(t *testing.T) {
|
|
|
|
w := &Watcher{
|
|
|
|
id: "test",
|
|
|
|
res: make(chan *registry.Result),
|
|
|
|
exit: make(chan bool),
|
|
|
|
}
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
w.res <- ®istry.Result{}
|
|
|
|
}()
|
|
|
|
|
|
|
|
_, 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()")
|
|
|
|
}
|
|
|
|
}
|