coredns/plugin/health/setup_test.go
Miek Gieben 890cdb5cab plugin/health: cleanups (#2811)
Small, trivial cleanup: got triggered because I saw a comment on how
health plugins polls other plugins which isn't true.

* Remove useless newHealth function
* healthParse -> parse
* Remove useless constants

Net deletion of code.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-05-04 16:06:04 -04:00

45 lines
856 B
Go

package health
import (
"testing"
"github.com/mholt/caddy"
)
func TestSetupHealth(t *testing.T) {
tests := []struct {
input string
shouldErr bool
}{
{`health`, false},
{`health localhost:1234`, false},
{`health localhost:1234 {
lameduck 4s
}`, false},
{`health bla:a`, false},
{`health bla`, true},
{`health bla bla`, true},
{`health localhost:1234 {
lameduck a
}`, true},
{`health localhost:1234 {
lamedudk 4
} `, 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 none for input %s", i, 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)
}
}
}
}