mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user