From 30f02c812f110e06b9e9b5a55cff2134d1313b17 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Mon, 18 Sep 2023 12:22:12 +0300 Subject: [PATCH] Replace path.Join with filepath.Join in tests --- fs_test.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/fs_test.go b/fs_test.go index 3e09e796fe..e38b1401eb 100644 --- a/fs_test.go +++ b/fs_test.go @@ -7,7 +7,7 @@ import ( "io" "math/rand" "os" - "path" + "path/filepath" "runtime" "sort" "testing" @@ -152,11 +152,10 @@ func TestServeFileHead(t *testing.T) { func TestServeFileSmallNoReadFrom(t *testing.T) { t.Parallel() - teststr := "hello, world!" - tempdir := t.TempDir() + expectedStr := "hello, world!" + tempFile := filepath.Join(t.TempDir(), "hello") - if err := os.WriteFile( - path.Join(tempdir, "hello"), []byte(teststr), 0o666); err != nil { + if err := os.WriteFile(tempFile, []byte(expectedStr), 0o666); err != nil { t.Fatal(err) } @@ -165,7 +164,7 @@ func TestServeFileSmallNoReadFrom(t *testing.T) { req.SetRequestURI("http://foobar.com/baz") ctx.Init(&req, nil, nil) - ServeFile(&ctx, path.Join(tempdir, "hello")) + ServeFile(&ctx, tempFile) reader, ok := ctx.Response.bodyStream.(*fsSmallFileReader) if !ok { @@ -180,13 +179,13 @@ func TestServeFileSmallNoReadFrom(t *testing.T) { t.Fatal(err) } - if n != int64(len(teststr)) { - t.Fatalf("expected %d bytes, got %d bytes", len(teststr), n) + if n != int64(len(expectedStr)) { + t.Fatalf("expected %d bytes, got %d bytes", len(expectedStr), n) } body := buf.String() - if body != teststr { - t.Fatalf("expected '%q'", teststr) + if body != expectedStr { + t.Fatalf("expected '%q'", expectedStr) } }