test: use t.TempDir
to create temporary test directory (#6164)
This commit is contained in:
parent
06cd843918
commit
b868350fc2
8 changed files with 30 additions and 77 deletions
|
@ -9,11 +9,7 @@ import (
|
|||
)
|
||||
|
||||
func setupProxyTargetCoreDNS(t *testing.T, fn func(string)) {
|
||||
tmpdir, err := os.MkdirTemp(os.TempDir(), "coredns")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(tmpdir)
|
||||
tmpdir := t.TempDir()
|
||||
|
||||
content := `
|
||||
example.org. IN SOA sns.dns.icann.org. noc.dns.icann.org. 1 3600 3600 3600 3600
|
||||
|
@ -23,7 +19,7 @@ google.com. IN A 172.217.25.110
|
|||
`
|
||||
|
||||
path := filepath.Join(tmpdir, "file")
|
||||
if err = os.WriteFile(path, []byte(content), 0644); err != nil {
|
||||
if err := os.WriteFile(path, []byte(content), 0644); err != nil {
|
||||
t.Fatalf("Could not write to temp file: %s", err)
|
||||
}
|
||||
defer os.Remove(path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue