Package list golang-github-go-kit-kit / c377c2ee-57ee-4295-ba5c-f8a0b0e527d1/main sd / consul / registrar_test.go
c377c2ee-57ee-4295-ba5c-f8a0b0e527d1/main

Tree @c377c2ee-57ee-4295-ba5c-f8a0b0e527d1/main (Download .tar.gz)

registrar_test.go @c377c2ee-57ee-4295-ba5c-f8a0b0e527d1/main

9a19822
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)
	}
}