Codebase list golang-github-go-kit-kit / dff50435-7a33-4f0c-bbdc-f455eb10d80a/upstream/0.12.0+git20220826.1.a7ba4fa sd / consul / registrar_test.go
dff50435-7a33-4f0c-bbdc-f455eb10d80a/upstream/0.12.0+git20220826.1.a7ba4fa

Tree @dff50435-7a33-4f0c-bbdc-f455eb10d80a/upstream/0.12.0+git20220826.1.a7ba4fa (Download .tar.gz)

registrar_test.go @dff50435-7a33-4f0c-bbdc-f455eb10d80a/upstream/0.12.0+git20220826.1.a7ba4faraw · history · blame

package consul

import (
	"testing"

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

	"github.com/go-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)
	}
}