mirror of
https://github.com/caddyserver/caddy.git
synced 2026-06-29 21:31:41 +00:00
Ensure some tests remove temporary directories they created
This commit is contained in:
parent
e2917784d0
commit
36f8759a7b
2 changed files with 15 additions and 9 deletions
|
|
@ -746,14 +746,16 @@ func TestFiles(t *testing.T) {
|
|||
|
||||
// Create directory / files from test case.
|
||||
if test.fileNames != nil {
|
||||
dirPath, err = ioutil.TempDir(fmt.Sprintf("%s", context.Root), "caddy_test")
|
||||
dirPath, err = ioutil.TempDir(fmt.Sprintf("%s", context.Root), "caddy_ctxtest")
|
||||
if err != nil {
|
||||
os.RemoveAll(dirPath)
|
||||
t.Fatalf(testPrefix+"Expected no error creating directory, got: '%s'", err.Error())
|
||||
}
|
||||
|
||||
for _, name := range test.fileNames {
|
||||
absFilePath := filepath.Join(dirPath, name)
|
||||
if err = ioutil.WriteFile(absFilePath, []byte(""), os.ModePerm); err != nil {
|
||||
os.RemoveAll(dirPath)
|
||||
t.Fatalf(testPrefix+"Expected no error creating file, got: '%s'", err.Error())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue