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
7 years ago
7 | 7 | "testing" |
8 | 8 | "time" |
9 | 9 | |
10 | "github.com/go-kit/kit/endpoint" | |
10 | 11 | "github.com/go-kit/kit/log" |
11 | "github.com/go-kit/kit/service" | |
12 | 12 | stdconsul "github.com/hashicorp/consul/api" |
13 | 13 | ) |
14 | 14 | |
40 | 40 | } |
41 | 41 | |
42 | 42 | // 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) { | |
44 | 44 | t.Logf("factory invoked for %q", instance) |
45 | return service.Fixed{}, nil, nil | |
45 | return endpoint.Nop, nil, nil | |
46 | 46 | } |
47 | subscriber, err := NewSubscriber( | |
47 | subscriber := NewSubscriber( | |
48 | 48 | client, |
49 | 49 | factory, |
50 | 50 | log.NewContext(logger).With("component", "subscriber"), |
52 | 52 | r.Tags, |
53 | 53 | true, |
54 | 54 | ) |
55 | if err != nil { | |
56 | t.Fatal(err) | |
57 | } | |
58 | 55 | |
59 | 56 | time.Sleep(time.Second) |
60 | 57 | |
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() | |
63 | 60 | if err != nil { |
64 | 61 | t.Error(err) |
65 | 62 | } |
66 | if want, have := 0, len(services); want != have { | |
63 | if want, have := 0, len(endpoints); want != have { | |
67 | 64 | t.Errorf("want %d, have %d", want, have) |
68 | 65 | } |
69 | 66 | |
74 | 71 | |
75 | 72 | time.Sleep(time.Second) |
76 | 73 | |
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() | |
79 | 76 | if err != nil { |
80 | 77 | t.Error(err) |
81 | 78 | } |
82 | if want, have := 1, len(services); want != have { | |
79 | if want, have := 1, len(endpoints); want != have { | |
83 | 80 | t.Errorf("want %d, have %d", want, have) |
84 | 81 | } |
85 | 82 | } |