aboutsummaryrefslogtreecommitdiff
path: root/fs_test.go
diff options
context:
space:
mode:
authorGravatar Oleksandr Redko <Oleksandr_Redko@epam.com> 2023-09-18 21:13:37 +0300
committerGravatar GitHub <noreply@github.com> 2023-09-18 20:13:37 +0200
commita5301d9edc3894e79ffcd1c9453be71a06c2fbe7 (patch)
tree08b495f1b4b915c7a23609fa7b4dd2095883f12e /fs_test.go
parentchore: move rsa.key, rsa.pem to test variables (#1621) (diff)
downloadfasthttp-a5301d9edc3894e79ffcd1c9453be71a06c2fbe7.tar.gz
fasthttp-a5301d9edc3894e79ffcd1c9453be71a06c2fbe7.tar.bz2
fasthttp-a5301d9edc3894e79ffcd1c9453be71a06c2fbe7.zip
Replace path.Join with filepath.Join in tests (#1623)
Diffstat (limited to 'fs_test.go')
-rw-r--r--fs_test.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/fs_test.go b/fs_test.go
index 3e09e79..e38b140 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)
}
}