...
1 package consul
2
3 import (
4 "testing"
5
6 stdconsul "github.com/hashicorp/consul/api"
7
8 "github.com/go-kit/log"
9 )
10
11 func TestRegistrar(t *testing.T) {
12 client := newTestClient([]*stdconsul.ServiceEntry{})
13 p := NewRegistrar(client, testRegistration, log.NewNopLogger())
14 if want, have := 0, len(client.entries); want != have {
15 t.Errorf("want %d, have %d", want, have)
16 }
17
18 p.Register()
19 if want, have := 1, len(client.entries); want != have {
20 t.Errorf("want %d, have %d", want, have)
21 }
22
23 p.Deregister()
24 if want, have := 0, len(client.entries); want != have {
25 t.Errorf("want %d, have %d", want, have)
26 }
27 }
28
View as plain text