diff --git a/client/node_selector_test.go b/client/node_selector_test.go index f1a436b7..64dae191 100644 --- a/client/node_selector_test.go +++ b/client/node_selector_test.go @@ -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{}, } - counts := map[string]int{} - 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) }