refactor(test): new apis for creating temporary files (#3605)

Replace MakeTempFile usage with MakeTempFilePath and MakeTempFileWithContent
helpers that automatically handle file lifecycle. This prevents resource
leaks by ensuring temporary files are properly closed.

Shoudld also make the tests easier to read.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
This commit is contained in:
Andrei Aaron
2025-12-05 09:54:38 +02:00
committed by GitHub
parent 92aee8ebce
commit 9dfa7c3ae6
46 changed files with 1321 additions and 2612 deletions
+1 -4
View File
@@ -4,7 +4,6 @@ package pprof_test
import (
"net/http"
"os"
"testing"
. "github.com/smartystreets/goconvey/convey"
@@ -29,9 +28,7 @@ func TestProfilingAuthz(t *testing.T) {
testCreds := test.GetBcryptCredString(adminUsername, adminPassword) +
test.GetBcryptCredString(username, password)
htpasswdPath := test.MakeHtpasswdFileFromString(testCreds)
defer os.Remove(htpasswdPath)
htpasswdPath := test.MakeHtpasswdFileFromString(t, testCreds)
conf := config.New()
conf.HTTP.Port = port