Switched health and autopath plugin to allow any plugins to be used instead of a hardcoded list. I did not switch federation over since it wasn't obvious that anything other than kubernetes could be used with it. Fixes #1291
31 lines
790 B
Go
31 lines
790 B
Go
package dnsserver
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestHandler(t *testing.T) {
|
|
tp := testPlugin{}
|
|
c := testConfig("dns", tp)
|
|
if _, err := NewServer("127.0.0.1:53", []*Config{c}); err != nil {
|
|
t.Errorf("Expected no error for NewServer, got %s", err)
|
|
}
|
|
if h := c.Handler("testplugin"); h != tp {
|
|
t.Errorf("Expected testPlugin from Handler, got %T", h)
|
|
}
|
|
if h := c.Handler("nothing"); h != nil {
|
|
t.Errorf("Expected nil from Handler, got %T", h)
|
|
}
|
|
}
|
|
|
|
func TestHandlers(t *testing.T) {
|
|
tp := testPlugin{}
|
|
c := testConfig("dns", tp)
|
|
if _, err := NewServer("127.0.0.1:53", []*Config{c}); err != nil {
|
|
t.Errorf("Expected no error for NewServer, got %s", err)
|
|
}
|
|
hs := c.Handlers()
|
|
if len(hs) != 1 || hs[0] != tp {
|
|
t.Errorf("Expected [testPlugin] from Handlers, got %v", hs)
|
|
}
|
|
}
|