Codebase list golang-github-go-kit-kit / a83f2ba5-b16e-4ce4-8519-5a89894e4275/main sd / consul / registrar_test.go
a83f2ba5-b16e-4ce4-8519-5a89894e4275/main

Tree @a83f2ba5-b16e-4ce4-8519-5a89894e4275/main (Download .tar.gz)

registrar_test.go @a83f2ba5-b16e-4ce4-8519-5a89894e4275/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)
	}
}