mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
This allows for advanced loadbalancing and maybe geoIP loadbalancing. Signed-off-by: Miek Gieben <miek@miek.nl>
35 lines
632 B
Go
35 lines
632 B
Go
package traffic
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/caddyserver/caddy"
|
|
)
|
|
|
|
func TestSetup(t *testing.T) {
|
|
tests := []struct {
|
|
input string
|
|
shouldErr bool
|
|
}{
|
|
// positive
|
|
{`traffic`, false},
|
|
// negative
|
|
{`traffic fleeb`, true},
|
|
}
|
|
|
|
for i, test := range tests {
|
|
c := caddy.NewTestController("dns", test.input)
|
|
err := parse(c)
|
|
|
|
if test.shouldErr && err == nil {
|
|
t.Errorf("Test %d: Expected error but found %s for input %s", i, err, test.input)
|
|
}
|
|
|
|
if err != nil {
|
|
if !test.shouldErr {
|
|
t.Errorf("Test %d: Expected no error but found one for input %s. Error was: %v", i, test.input, err)
|
|
}
|
|
}
|
|
}
|
|
}
|