fix the test

This commit is contained in:
Asim 2015-12-08 00:08:23 +00:00
parent 6ef3b81a18
commit 727bba15b8

View File

@ -4,10 +4,13 @@ import (
"testing"
"github.com/micro/go-micro/registry"
"golang.org/x/net/context"
)
func TestNodeSelector(t *testing.T) {
services := []*registry.Service{
type mockRegistry struct{}
func (m *mockRegistry) GetService(service string) ([]*registry.Service, error) {
return []*registry.Service{
{
Name: "foo",
Version: "1.0.0",
@ -30,12 +33,33 @@ func TestNodeSelector(t *testing.T) {
},
},
},
}, nil
}
func (m *mockRegistry) ListServices() ([]*registry.Service, error) {
return []*registry.Service{}, nil
}
func (m *mockRegistry) Register(s *registry.Service) error {
return nil
}
func (m *mockRegistry) Deregister(s *registry.Service) error {
return nil
}
func (m *mockRegistry) Watch() (registry.Watcher, error) {
return nil, nil
}
func TestNodeSelector(t *testing.T) {
counts := map[string]int{}
n := &nodeSelector{
&mockRegistry{},
}
for i := 0; i < 100; i++ {
n, err := nodeSelector(services)
n, err := n.Retrieve(context.Background(), newRpcRequest("foo", "Foo.Bar", nil, ""))
if err != nil {
t.Errorf("Expected node, got err: %v", err)
}