Delete temp test file when exist

pull/247/head
HFO4 5 years ago
parent ec7ab83d7c
commit c5493fd1f1

@ -3,6 +3,7 @@ package conf
import ( import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"io/ioutil" "io/ioutil"
"os"
"testing" "testing"
) )
@ -28,6 +29,7 @@ Host = 127.0.0.1:3306
Name = v3 Name = v3
TablePrefix = v3_` TablePrefix = v3_`
err := ioutil.WriteFile("testConf.ini", []byte(testCase), 0644) err := ioutil.WriteFile("testConf.ini", []byte(testCase), 0644)
defer func() { err = os.Remove("testConf.ini") }()
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -47,6 +49,7 @@ Host = 127.0.0.1:3306
Name = v3 Name = v3
TablePrefix = v3_` TablePrefix = v3_`
err := ioutil.WriteFile("testConf.ini", []byte(testCase), 0644) err := ioutil.WriteFile("testConf.ini", []byte(testCase), 0644)
defer func() { err = os.Remove("testConf.ini") }()
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -67,6 +70,7 @@ Host = 127.0.0.1:3306
Name = v3 Name = v3
TablePrefix = v3_` TablePrefix = v3_`
err := ioutil.WriteFile("testConf.ini", []byte(testCase), 0644) err := ioutil.WriteFile("testConf.ini", []byte(testCase), 0644)
defer func() { err = os.Remove("testConf.ini") }()
if err != nil { if err != nil {
panic(err) panic(err)
} }

Loading…
Cancel
Save