aboutsummaryrefslogtreecommitdiff
path: root/plugin/auto/walk_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/auto/walk_test.go')
-rw-r--r--plugin/auto/walk_test.go17
1 files changed, 5 insertions, 12 deletions
diff --git a/plugin/auto/walk_test.go b/plugin/auto/walk_test.go
index bee955c10..062c99243 100644
--- a/plugin/auto/walk_test.go
+++ b/plugin/auto/walk_test.go
@@ -18,14 +18,10 @@ www IN A 127.0.0.1
`
func TestWalk(t *testing.T) {
- tempdir, err := createFiles()
+ tempdir, err := createFiles(t)
if err != nil {
- if tempdir != "" {
- os.RemoveAll(tempdir)
- }
t.Fatal(err)
}
- defer os.RemoveAll(tempdir)
ldr := loader{
directory: tempdir,
@@ -65,11 +61,8 @@ func TestWalkNonExistent(t *testing.T) {
a.Walk()
}
-func createFiles() (string, error) {
- dir, err := os.MkdirTemp(os.TempDir(), "coredns")
- if err != nil {
- return dir, err
- }
+func createFiles(t *testing.T) (string, error) {
+ dir := t.TempDir()
for _, name := range dbFiles {
if err := os.WriteFile(filepath.Join(dir, name), []byte(zoneContent), 0644); err != nil {
@@ -77,10 +70,10 @@ func createFiles() (string, error) {
}
}
// symlinks
- if err = os.Symlink(filepath.Join(dir, "db.example.org"), filepath.Join(dir, "db.example.com")); err != nil {
+ if err := os.Symlink(filepath.Join(dir, "db.example.org"), filepath.Join(dir, "db.example.com")); err != nil {
return dir, err
}
- if err = os.Symlink(filepath.Join(dir, "db.example.org"), filepath.Join(dir, "aa.example.com")); err != nil {
+ if err := os.Symlink(filepath.Join(dir, "db.example.org"), filepath.Join(dir, "aa.example.com")); err != nil {
return dir, err
}