Files
coredns/plugin/errors/setup_test.go

34 lines
718 B
Go
Raw Normal View History

package errors
2016-03-18 20:57:35 +00:00
import (
"testing"
"github.com/mholt/caddy"
)
2016-03-18 20:57:35 +00:00
func TestErrorsParse(t *testing.T) {
tests := []struct {
inputErrorsRules string
shouldErr bool
2016-03-18 20:57:35 +00:00
}{
{`errors`, false},
{`errors stdout`, false},
{`errors errors.txt`, true},
{`errors visible`, true},
{`errors { log visible }`, true},
{`errors
errors `, true},
{`errors a b`, true},
2016-03-18 20:57:35 +00:00
}
for i, test := range tests {
c := caddy.NewTestController("dns", test.inputErrorsRules)
_, err := errorsParse(c)
2016-03-18 20:57:35 +00:00
if err == nil && test.shouldErr {
t.Errorf("Test %d didn't error, but it should have", i)
} else if err != nil && !test.shouldErr {
t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err)
}
}
}