middleware/auto: handle non-existent directory (#385)

Don't panic on a non-existent directory. Add test for it as well.

Fixes #384
This commit is contained in:
Miek Gieben
2016-11-06 19:37:43 +00:00
committed by GitHub
parent 243797a387
commit d3dae8d77f
2 changed files with 20 additions and 1 deletions

View File

@@ -52,6 +52,25 @@ func TestWalk(t *testing.T) {
}
}
func TestWalkNonExistent(t *testing.T) {
log.SetOutput(ioutil.Discard)
nonExistingDir := "highly_unlikely_to_exist_dir"
ldr := loader{
directory: nonExistingDir,
re: regexp.MustCompile(`db\.(.*)`),
template: `${1}`,
}
a := Auto{
loader: ldr,
Zones: &Zones{},
}
a.Walk()
}
func createFiles() (string, error) {
dir, err := ioutil.TempDir(os.TempDir(), "coredns")
if err != nil {