From c5493fd1f13c2557e20a74f667f38c8e2af71baf Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Sat, 9 Nov 2019 18:09:32 +0800 Subject: [PATCH] Delete temp test file when exist --- pkg/conf/conf_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/conf/conf_test.go b/pkg/conf/conf_test.go index dad078e..0eb2073 100644 --- a/pkg/conf/conf_test.go +++ b/pkg/conf/conf_test.go @@ -3,6 +3,7 @@ package conf import ( "github.com/stretchr/testify/assert" "io/ioutil" + "os" "testing" ) @@ -28,6 +29,7 @@ Host = 127.0.0.1:3306 Name = v3 TablePrefix = v3_` err := ioutil.WriteFile("testConf.ini", []byte(testCase), 0644) + defer func() { err = os.Remove("testConf.ini") }() if err != nil { panic(err) } @@ -47,6 +49,7 @@ Host = 127.0.0.1:3306 Name = v3 TablePrefix = v3_` err := ioutil.WriteFile("testConf.ini", []byte(testCase), 0644) + defer func() { err = os.Remove("testConf.ini") }() if err != nil { panic(err) } @@ -67,6 +70,7 @@ Host = 127.0.0.1:3306 Name = v3 TablePrefix = v3_` err := ioutil.WriteFile("testConf.ini", []byte(testCase), 0644) + defer func() { err = os.Remove("testConf.ini") }() if err != nil { panic(err) }