2019-01-18 20:29:17 +03:00
|
|
|
package memory
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-08-19 17:47:17 +03:00
|
|
|
"github.com/unistack-org/micro/v3/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),
|
2020-06-25 13:02:35 +03:00
|
|
|
wo: registry.WatchOptions{
|
|
|
|
Domain: registry.WildcardDomain,
|
|
|
|
},
|
2019-01-18 20:29:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
go func() {
|
2020-06-25 13:02:35 +03:00
|
|
|
w.res <- ®istry.Result{
|
|
|
|
Service: ®istry.Service{Name: "foo"},
|
|
|
|
}
|
2019-01-18 20:29:17 +03: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()")
|
|
|
|
}
|
|
|
|
}
|