test: refactor tests and cleanup imports

- Replace `ioutil.TempFile` with `os.CreateTemp` in `TestEmptyDirectory` test function
- Remove unused import `io/ioutil` in `serve_test.go`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2024-02-17 16:37:27 +08:00
parent 9f124f7410
commit 6e6360c0c7
No known key found for this signature in database
1 changed files with 1 additions and 3 deletions

View File

@ -2,7 +2,6 @@ package static
import ( import (
"context" "context"
"io/ioutil"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"os" "os"
@ -23,9 +22,8 @@ func PerformRequest(r http.Handler, method, path string) *httptest.ResponseRecor
} }
func TestEmptyDirectory(t *testing.T) { func TestEmptyDirectory(t *testing.T) {
// SETUP file
testRoot, _ := os.Getwd() testRoot, _ := os.Getwd()
f, err := ioutil.TempFile(testRoot, "") f, err := os.CreateTemp(testRoot, "")
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }