coredns/plugin/reload/setup_test.go
John Belamaric 0b35d4d28f Reload hook (#1445)
* Add reload directive

* gofmt

* Fix default jitter and error message

* remove unneeded call to NextArg, add a couple negative setup tests

* Review feedback
2018-01-27 10:42:57 +00:00

39 lines
940 B
Go

package reload
import (
"testing"
"github.com/mholt/caddy"
)
func TestSetupReload(t *testing.T) {
c := caddy.NewTestController("dns", `reload`)
if err := setup(c); err != nil {
t.Fatalf("Expected no errors, but got: %v", err)
}
c = caddy.NewTestController("dns", `reload 10s`)
if err := setup(c); err != nil {
t.Fatalf("Expected no errors, but got: %v", err)
}
c = caddy.NewTestController("dns", `reload 10s 2s`)
if err := setup(c); err != nil {
t.Fatalf("Expected no errors, but got: %v", err)
}
c = caddy.NewTestController("dns", `reload foo`)
if err := setup(c); err == nil {
t.Fatalf("Expected errors, but got: %v", err)
}
c = caddy.NewTestController("dns", `reload 10s foo`)
if err := setup(c); err == nil {
t.Fatalf("Expected errors, but got: %v", err)
}
c = caddy.NewTestController("dns", `reload 10s 5s foo`)
if err := setup(c); err == nil {
t.Fatalf("Expected errors, but got: %v", err)
}
}