diff --git a/sd/eureka/instancer_test.go b/sd/eureka/instancer_test.go index a681697..94e40b3 100644 --- a/sd/eureka/instancer_test.go +++ b/sd/eureka/instancer_test.go @@ -1,23 +1,17 @@ package eureka import ( - "io" "testing" "time" "github.com/hudl/fargo" - "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/sd" ) var _ sd.Instancer = &Instancer{} // API check func TestInstancer(t *testing.T) { - factory := func(string) (endpoint.Endpoint, io.Closer, error) { - return endpoint.Nop, nil, nil - } - connection := &testConnection{ instances: []*fargo.Instance{instanceTest1}, application: appUpdateTest, @@ -27,13 +21,12 @@ instancer := NewInstancer(connection, appNameTest, loggerTest) defer instancer.Stop() - endpointer := sd.NewEndpointer(instancer, factory, loggerTest) - endpoints, err := endpointer.Endpoints() - if err != nil { - t.Fatal(err) + state := instancer.State() + if state.Err != nil { + t.Fatal(state.Err) } - if want, have := 1, len(endpoints); want != have { + if want, have := 1, len(state.Instances); want != have { t.Errorf("want %d, have %d", want, have) } } diff --git a/sd/eureka/integration_test.go b/sd/eureka/integration_test.go index c2ced6a..2a8dfd6 100644 --- a/sd/eureka/integration_test.go +++ b/sd/eureka/integration_test.go @@ -3,16 +3,13 @@ package eureka import ( - "io" "os" "testing" "time" "github.com/hudl/fargo" - "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/log" - "github.com/go-kit/kit/sd" ) // Package sd/eureka provides a wrapper around the Netflix Eureka service @@ -50,25 +47,20 @@ // This should be enough time for the Eureka server response cache to update. time.Sleep(time.Second) - // Build a Eureka subscriber. - factory := func(instance string) (endpoint.Endpoint, io.Closer, error) { - t.Logf("factory invoked for %q", instance) - return endpoint.Nop, nil, nil - } + // Build a Eureka instancer. instancer := NewInstancer( &fargoConnection, appNameTest, log.With(logger, "component", "instancer"), ) defer instancer.Stop() - endpointer := sd.NewEndpointer(instancer, factory, log.With(logger, "component", "endpointer")) - // We should have one endpoint immediately after subscriber instantiation. - endpoints, err := endpointer.Endpoints() - if err != nil { - t.Error(err) + // We should have one instance immediately after subscriber instantiation. + state := instancer.State() + if state.Err != nil { + t.Error(state.Err) } - if want, have := 1, len(endpoints); want != have { + if want, have := 1, len(state.Instances); want != have { t.Errorf("want %d, have %d", want, have) } @@ -81,12 +73,12 @@ // configured with the properties mentioned in the function comments. time.Sleep(2 * time.Second) - // Now we should have two endpoints. - endpoints, err = endpointer.Endpoints() - if err != nil { - t.Error(err) + // Now we should have two instances. + state = instancer.State() + if state.Err != nil { + t.Error(state.Err) } - if want, have := 2, len(endpoints); want != have { + if want, have := 2, len(state.Instances); want != have { t.Errorf("want %d, have %d", want, have) }