diff options
Diffstat (limited to 'plugin/file/setup_test.go')
-rw-r--r-- | plugin/file/setup_test.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/plugin/file/setup_test.go b/plugin/file/setup_test.go index f6252759b..6a1d5e790 100644 --- a/plugin/file/setup_test.go +++ b/plugin/file/setup_test.go @@ -2,6 +2,7 @@ package file import ( "testing" + "time" "github.com/coredns/coredns/plugin/test" @@ -90,3 +91,35 @@ func TestFileParse(t *testing.T) { } } } + +func TestParseReload(t *testing.T) { + name, rm, err := test.TempFile(".", dbMiekNL) + if err != nil { + t.Fatal(err) + } + defer rm() + + tests := []struct { + input string + reload time.Duration + }{ + { + `file ` + name + ` example.org.`, + 1 * time.Minute, + }, + { + `file ` + name + ` example.org. { + reload 5s + }`, + 5 * time.Second, + }, + } + + for i, test := range tests { + c := caddy.NewTestController("dns", test.input) + z, _ := fileParse(c) + if x := z.Z["example.org."].ReloadInterval; x != test.reload { + t.Errorf("Test %d expected reload to be %s, but got %s", i, test.reload, x) + } + } +} |