Files
coredns/plugin/any/setup_test.go
Immanuel Tikhonov 4c07a287da fix: reject invalid any and local config (#8133)
Signed-off-by: immanuwell <pchpr.00@list.ru>
2026-05-31 15:41:27 -07:00

36 lines
844 B
Go

package any
import (
"testing"
"github.com/coredns/caddy"
"github.com/coredns/coredns/core/dnsserver"
)
func TestSetup(t *testing.T) {
c := caddy.NewTestController("dns", `any`)
if err := setup(c); err != nil {
t.Fatalf("Expected no errors, but got: %v", err)
}
// Check that the plugin was added to the config
cfg := dnsserver.GetConfig(c)
if len(cfg.Plugin) == 0 {
t.Error("Expected plugin to be added to config")
}
}
func TestSetupRejectsArgs(t *testing.T) {
c := caddy.NewTestController("dns", `any example.org`)
if err := setup(c); err == nil {
t.Fatal("expected error for unexpected argument, got nil")
}
}
func TestSetupRejectsBlockOptions(t *testing.T) {
c := caddy.NewTestController("dns", `any { foo }`)
if err := setup(c); err == nil {
t.Fatal("expected error for unexpected block option, got nil")
}
}