Skip to content

Commit

Permalink
test: refactor to use WriteString (#1546)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear authored Apr 28, 2023
1 parent d2f0d17 commit 1dcf562
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion brotli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestCompressHandlerBrotliLevel(t *testing.T) {

expectedBody := string(createFixedBody(2e4))
h := CompressHandlerBrotliLevel(func(ctx *RequestCtx) {
ctx.Write([]byte(expectedBody)) //nolint:errcheck
ctx.WriteString(expectedBody) //nolint:errcheck
}, CompressBrotliDefaultCompression, CompressDefaultCompression)

var ctx RequestCtx
Expand Down
4 changes: 2 additions & 2 deletions examples/multidomain/multidomain.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func main() {
panic(err)
}
domains["localhost:8080"] = func(ctx *fasthttp.RequestCtx) {
ctx.Write([]byte("You are accessing to localhost:8080\n"))
ctx.WriteString("You are accessing to localhost:8080\n")
}

err = server.AppendCertEmbed(cert, priv)
Expand All @@ -51,7 +51,7 @@ func main() {
panic(err)
}
domains["127.0.0.1:8080"] = func(ctx *fasthttp.RequestCtx) {
ctx.Write([]byte("You are accessing to 127.0.0.1:8080\n"))
ctx.WriteString("You are accessing to 127.0.0.1:8080\n")
}

err = server.AppendCertEmbed(cert, priv)
Expand Down
6 changes: 3 additions & 3 deletions http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ func TestResponseGzipStream(t *testing.T) {
fmt.Fprintf(w, "foo")
w.Flush()
time.Sleep(time.Millisecond)
_, _ = w.Write([]byte("barbaz"))
_, _ = w.WriteString("barbaz")
_ = w.Flush()
time.Sleep(time.Millisecond)
_, _ = fmt.Fprintf(w, "1234")
Expand All @@ -1390,11 +1390,11 @@ func TestResponseDeflateStream(t *testing.T) {
t.Fatalf("IsBodyStream must return false")
}
r.SetBodyStreamWriter(func(w *bufio.Writer) {
_, _ = w.Write([]byte("foo"))
_, _ = w.WriteString("foo")
_ = w.Flush()
_, _ = fmt.Fprintf(w, "barbaz")
_ = w.Flush()
_, _ = w.Write([]byte("1234"))
_, _ = w.WriteString("1234")
if err := w.Flush(); err != nil {
t.Fatalf("unexpected error: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1942,7 +1942,7 @@ func TestCompressHandler(t *testing.T) {

expectedBody := string(createFixedBody(2e4))
h := CompressHandler(func(ctx *RequestCtx) {
ctx.Write([]byte(expectedBody)) //nolint:errcheck
ctx.WriteString(expectedBody) //nolint:errcheck
})

var ctx RequestCtx
Expand Down Expand Up @@ -2610,7 +2610,7 @@ func TestRequestCtxNoHijackNoResponse(t *testing.T) {

s := &Server{
Handler: func(ctx *RequestCtx) {
io.WriteString(ctx, "test") //nolint:errcheck
ctx.WriteString("test") //nolint:errcheck
ctx.HijackSetNoResponse(true)
},
}
Expand Down

0 comments on commit 1dcf562

Please sign in to comment.