2020-05-27 13:03:24 -07:00
|
|
|
package wgsd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-11-24 14:59:59 -08:00
|
|
|
"github.com/coredns/caddy"
|
2020-05-27 13:03:24 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSetup(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
name string
|
|
|
|
input string
|
|
|
|
expectErr bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
"valid input",
|
|
|
|
"wgsd example.com. wg0",
|
|
|
|
false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"missing token",
|
|
|
|
"wgsd example.com.",
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"too many tokens",
|
|
|
|
"wgsd example.com. wg0 extra",
|
|
|
|
true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range testCases {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
c := caddy.NewTestController("dns", tc.input)
|
|
|
|
err := setup(c)
|
|
|
|
if (err != nil) != tc.expectErr {
|
|
|
|
t.Fatalf("expectErr: %v, got err=%v", tc.expectErr, err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|