Codebase list golang-github-go-kit-kit / 0c243515-0bf2-4b25-8735-9c1038fa7c1b/v0.5.0 sd / consul / registrar_test.go
0c243515-0bf2-4b25-8735-9c1038fa7c1b/v0.5.0

Tree @0c243515-0bf2-4b25-8735-9c1038fa7c1b/v0.5.0 (Download .tar.gz)

registrar_test.go @0c243515-0bf2-4b25-8735-9c1038fa7c1b/v0.5.0raw · history · blame

package consul

import (
	"testing"

	stdconsul "github.com/hashicorp/consul/api"

	"github.com/go-kit/kit/log"
)

func TestRegistrar(t *testing.T) {
	client := newTestClient([]*stdconsul.ServiceEntry{})
	p := NewRegistrar(client, testRegistration, log.NewNopLogger())
	if want, have := 0, len(client.entries); want != have {
		t.Errorf("want %d, have %d", want, have)
	}

	p.Register()
	if want, have := 1, len(client.entries); want != have {
		t.Errorf("want %d, have %d", want, have)
	}

	p.Deregister()
	if want, have := 0, len(client.entries); want != have {
		t.Errorf("want %d, have %d", want, have)
	}
}