Skip to content

Commit

Permalink
Ensure open files are closed before cleaning them up
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
  • Loading branch information
Aneurysm9 committed Aug 18, 2022
1 parent dfe9160 commit 6e91c80
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func TestStatic(t *testing.T) {
meterProvider, metricExporter := metrictest.NewTestMeterProvider()
file, err := os.CreateTemp("", "static-*.html")
require.NoError(t, err)
defer file.Close()
defer os.Remove(file.Name())
_, err = file.WriteString(beego.Htmlunquote("<h1>Hello, world!</h1>"))
require.NoError(t, err)
Expand Down Expand Up @@ -238,6 +239,7 @@ func TestRender(t *testing.T) {
// Create the view
file, err := os.CreateTemp(dir, "*index.tpl")
require.NoError(t, err)
defer file.Close()
_, err = file.WriteString(htmlStr)
require.NoError(t, err)
// Add path to view path
Expand Down

0 comments on commit 6e91c80

Please sign in to comment.