From 8dcbc41e3732676a8eead300d18dd9bc26844648 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Fri, 10 Feb 2023 12:17:56 +0200 Subject: [PATCH] test: use T.TempDir instead of MkdirTemp (#1485) * test: use T.TempDir instead of MkdirTemp * Fix test by adding reader.ff.Release() --- fs_test.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/fs_test.go b/fs_test.go index 22a9b33c2b..7e81ee63dc 100644 --- a/fs_test.go +++ b/fs_test.go @@ -153,12 +153,7 @@ func TestServeFileSmallNoReadFrom(t *testing.T) { t.Parallel() teststr := "hello, world!" - - tempdir, err := os.MkdirTemp("", "httpexpect") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(tempdir) + tempdir := t.TempDir() if err := os.WriteFile( path.Join(tempdir, "hello"), []byte(teststr), 0666); err != nil { @@ -176,6 +171,7 @@ func TestServeFileSmallNoReadFrom(t *testing.T) { if !ok { t.Fatal("expected fsSmallFileReader") } + defer reader.ff.Release() buf := bytes.NewBuffer(nil)