1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-11-29 21:47:44 +02:00

move selector

This commit is contained in:
Asim Aslam
2020-12-12 20:14:50 +00:00
parent de4f3ee4a2
commit df687fe5d4
35 changed files with 58 additions and 281 deletions

32
selector/default_test.go Normal file
View File

@@ -0,0 +1,32 @@
package selector
import (
"os"
"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]++
}
if len(os.Getenv("IN_TRAVIS_CI")) == 0 {
t.Logf("Selector Counts %v", counts)
}
}