🔥 Delete temp files in testing code
This commit is contained in:
parent
b8fc873850
commit
25ed67b2e9
2 changed files with 6 additions and 4 deletions
|
|
@ -12,7 +12,9 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
conf, err := config.LoadFromToml(getTomlFile())
|
||||
f := getTomlFile()
|
||||
defer os.Remove(f)
|
||||
conf, err := config.LoadFromToml(f)
|
||||
quitErr(err)
|
||||
fmt.Printf("%+v\n", conf)
|
||||
|
||||
|
|
@ -28,6 +30,7 @@ func main() {
|
|||
fmt.Println(string(out))
|
||||
fmt.Println(serv.ID)
|
||||
}
|
||||
|
||||
func quitErr(err error) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -36,9 +39,7 @@ func quitErr(err error) {
|
|||
|
||||
func getTomlFile() string {
|
||||
tmp, err := os.CreateTemp("", "*.toml")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
quitErr(err)
|
||||
defer tmp.Close()
|
||||
|
||||
p := tmp.Name()
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ func TestLoadTomlMissing(t *testing.T) {
|
|||
|
||||
func TestLoadTomlGood(t *testing.T) {
|
||||
tmp, _ := os.CreateTemp("", "*.toml")
|
||||
defer os.Remove(tmp.Name())
|
||||
defer tmp.Close()
|
||||
fmt.Fprintln(tmp, `name = "Cool"`)
|
||||
fmt.Fprintln(tmp, "[conn]")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue