Skip to content

Commit

Permalink
tests: add missing close
Browse files Browse the repository at this point in the history
when writing tmp file.
  • Loading branch information
sni committed Jan 30, 2025
1 parent 88b7ab5 commit f9685f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/snclient/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,15 @@ func (config *Config) WriteINI(iniPath string) error {
if err != nil {
return fmt.Errorf("failed to write ini %s: %s", iniPath, err.Error())
}
defer file.Close()

_, err = file.WriteString(configData)
if err != nil {
LogDebug(file.Close())

return fmt.Errorf("failed to write ini %s: %s", iniPath, err.Error())
}

err = file.Close()
if err != nil {
return fmt.Errorf("failed to write ini %s: %s", iniPath, err.Error())
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/snclient/snclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ use ssl = false
password = test
`)
require.NoErrorf(t, err, "tmp include created")
err = tmpInclude.Close()
require.NoErrorf(t, err, "tmp include created")

snc := StartTestAgent(t, config)

Expand Down

0 comments on commit f9685f2

Please sign in to comment.