Codebase list golang-github-go-kit-kit / run/d2f2902b-79c4-43cd-8c09-341e33fc6017/main sd / consul / registrar_test.go
run/d2f2902b-79c4-43cd-8c09-341e33fc6017/main

Tree @run/d2f2902b-79c4-43cd-8c09-341e33fc6017/main (Download .tar.gz)

registrar_test.go @run/d2f2902b-79c4-43cd-8c09-341e33fc6017/mainraw · 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)
	}
}