Package list golang-github-go-kit-kit / 1fe030b
Remove service leftovers in consul integration test During a brief and forgotten period there was the Service abstraction which was used in the integration test of the Consul sd package. As it is guarded with a build tag it likely was missed, this change-set addresses this and removes all traces of the forgotten abstraction. Fixes #366 Alexander Simmerl 5 years ago
1 changed file(s) with 10 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
77 "testing"
88 "time"
99
10 "github.com/go-kit/kit/endpoint"
1011 "github.com/go-kit/kit/log"
11 "github.com/go-kit/kit/service"
1212 stdconsul "github.com/hashicorp/consul/api"
1313 )
1414
4040 }
4141
4242 // Build a subscriber on r.Name + r.Tags.
43 factory := func(instance string) (service.Service, io.Closer, error) {
43 factory := func(instance string) (endpoint.Endpoint, io.Closer, error) {
4444 t.Logf("factory invoked for %q", instance)
45 return service.Fixed{}, nil, nil
45 return endpoint.Nop, nil, nil
4646 }
47 subscriber, err := NewSubscriber(
47 subscriber := NewSubscriber(
4848 client,
4949 factory,
5050 log.NewContext(logger).With("component", "subscriber"),
5252 r.Tags,
5353 true,
5454 )
55 if err != nil {
56 t.Fatal(err)
57 }
5855
5956 time.Sleep(time.Second)
6057
61 // Before we publish, we should have no services.
62 services, err := subscriber.Services()
58 // Before we publish, we should have no endpoints.
59 endpoints, err := subscriber.Endpoints()
6360 if err != nil {
6461 t.Error(err)
6562 }
66 if want, have := 0, len(services); want != have {
63 if want, have := 0, len(endpoints); want != have {
6764 t.Errorf("want %d, have %d", want, have)
6865 }
6966
7471
7572 time.Sleep(time.Second)
7673
77 // Now we should have one active service.
78 services, err = subscriber.Services()
74 // Now we should have one active endpoints.
75 endpoints, err = subscriber.Endpoints()
7976 if err != nil {
8077 t.Error(err)
8178 }
82 if want, have := 1, len(services); want != have {
79 if want, have := 1, len(endpoints); want != have {
8380 t.Errorf("want %d, have %d", want, have)
8481 }
8582 }