mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-24 10:07:04 +02:00
29 lines
513 B
Go
29 lines
513 B
Go
package selector
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/micro/go-micro/registry/mock"
|
|
)
|
|
|
|
func TestDefaultSelector(t *testing.T) {
|
|
counts := map[string]int{}
|
|
|
|
rs := newDefaultSelector(Registry(mock.NewRegistry()))
|
|
|
|
next, err := rs.Select("foo")
|
|
if err != nil {
|
|
t.Errorf("Unexpected error calling default 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("Default Counts %v", counts)
|
|
}
|