mirror of
https://github.com/go-micro/go-micro.git
synced 2024-11-24 08:02:32 +02:00
f23638c036
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
30 lines
552 B
Go
30 lines
552 B
Go
package selector
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/micro/go-micro/v2/registry/memory"
|
|
)
|
|
|
|
func TestRegistrySelector(t *testing.T) {
|
|
counts := map[string]int{}
|
|
|
|
r := memory.NewRegistry(memory.Services(testData))
|
|
cache := NewSelector(Registry(r))
|
|
|
|
next, err := cache.Select("foo")
|
|
if err != nil {
|
|
t.Errorf("Unexpected error calling cache select: %v", err)
|
|
}
|
|
|
|
for i := 0; i < 100; i++ {
|
|
node, err := next()
|
|
if err != nil {
|
|
t.Errorf("Expected node err, got err: %v", err)
|
|
}
|
|
counts[node.Id]++
|
|
}
|
|
|
|
t.Logf("Selector Counts %v", counts)
|
|
}
|