mirror of
https://github.com/project-zot/zot.git
synced 2026-06-19 22:27:58 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user