mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-18 08:26:38 +02:00
4107733453
* PoC: memory registry using maps instead of slice madness * Updated proto and handlers. Fixed tests across codebase. * Implemented ttl pruning for memory registry * Added extensive memory registry tests * Squased a bunch of bugs * Proto indent; memory.Registry.String() returns "memory" * Write a test to prove memory registry TTLs are busted Signed-off-by: Erik Hollensbe <github@hollensbe.org> * Additional memory testing and fixups: * DefaultTTL removed * When TTL == 0, it is automatically removed from expiry conditions * Additional improvements to new tests Signed-off-by: Erik Hollensbe <github@hollensbe.org>
30 lines
549 B
Go
30 lines
549 B
Go
package selector
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/micro/go-micro/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)
|
|
}
|