🔍 fix unhandled errors in helpers_test.go (#2058)

* fix unhandled errors

* fix unhandled error in cache package test

* omit variable type

* omit variable type

* rename variable because collide with the imported package name

* handle file error on closing

* fix unhandled in common_linux.go

* fix unhandled errors in helpers_test.go
pull/2060/head
Amir Hossein 2022-08-29 16:42:12 +04:30 committed by GitHub
parent 6272d759eb
commit 0734c9d3fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 5 deletions

View File

@ -22,7 +22,8 @@ func Test_Utils_ETag(t *testing.T) {
t.Run("Not Status OK", func(t *testing.T) { t.Run("Not Status OK", func(t *testing.T) {
c := app.AcquireCtx(&fasthttp.RequestCtx{}) c := app.AcquireCtx(&fasthttp.RequestCtx{})
defer app.ReleaseCtx(c) defer app.ReleaseCtx(c)
c.SendString("Hello, World!") err := c.SendString("Hello, World!")
utils.AssertEqual(t, nil, err)
c.Status(201) c.Status(201)
setETag(c, false) setETag(c, false)
utils.AssertEqual(t, "", string(c.Response().Header.Peek(HeaderETag))) utils.AssertEqual(t, "", string(c.Response().Header.Peek(HeaderETag)))
@ -38,7 +39,8 @@ func Test_Utils_ETag(t *testing.T) {
t.Run("Has HeaderIfNoneMatch", func(t *testing.T) { t.Run("Has HeaderIfNoneMatch", func(t *testing.T) {
c := app.AcquireCtx(&fasthttp.RequestCtx{}) c := app.AcquireCtx(&fasthttp.RequestCtx{})
defer app.ReleaseCtx(c) defer app.ReleaseCtx(c)
c.SendString("Hello, World!") err := c.SendString("Hello, World!")
utils.AssertEqual(t, nil, err)
c.Request().Header.Set(HeaderIfNoneMatch, `"13-1831710635"`) c.Request().Header.Set(HeaderIfNoneMatch, `"13-1831710635"`)
setETag(c, false) setETag(c, false)
utils.AssertEqual(t, 304, c.Response().StatusCode()) utils.AssertEqual(t, 304, c.Response().StatusCode())
@ -49,7 +51,8 @@ func Test_Utils_ETag(t *testing.T) {
t.Run("No HeaderIfNoneMatch", func(t *testing.T) { t.Run("No HeaderIfNoneMatch", func(t *testing.T) {
c := app.AcquireCtx(&fasthttp.RequestCtx{}) c := app.AcquireCtx(&fasthttp.RequestCtx{})
defer app.ReleaseCtx(c) defer app.ReleaseCtx(c)
c.SendString("Hello, World!") err := c.SendString("Hello, World!")
utils.AssertEqual(t, nil, err)
setETag(c, false) setETag(c, false)
utils.AssertEqual(t, `"13-1831710635"`, string(c.Response().Header.Peek(HeaderETag))) utils.AssertEqual(t, `"13-1831710635"`, string(c.Response().Header.Peek(HeaderETag)))
}) })
@ -60,7 +63,8 @@ func Benchmark_Utils_ETag(b *testing.B) {
app := New() app := New()
c := app.AcquireCtx(&fasthttp.RequestCtx{}) c := app.AcquireCtx(&fasthttp.RequestCtx{})
defer app.ReleaseCtx(c) defer app.ReleaseCtx(c)
c.SendString("Hello, World!") err := c.SendString("Hello, World!")
utils.AssertEqual(b, nil, err)
for n := 0; n < b.N; n++ { for n := 0; n < b.N; n++ {
setETag(c, false) setETag(c, false)
} }
@ -73,7 +77,8 @@ func Test_Utils_ETag_Weak(t *testing.T) {
t.Run("Set Weak", func(t *testing.T) { t.Run("Set Weak", func(t *testing.T) {
c := app.AcquireCtx(&fasthttp.RequestCtx{}) c := app.AcquireCtx(&fasthttp.RequestCtx{})
defer app.ReleaseCtx(c) defer app.ReleaseCtx(c)
c.SendString("Hello, World!") err := c.SendString("Hello, World!")
utils.AssertEqual(t, nil, err)
setETag(c, true) setETag(c, true)
utils.AssertEqual(t, `W/"13-1831710635"`, string(c.Response().Header.Peek(HeaderETag))) utils.AssertEqual(t, `W/"13-1831710635"`, string(c.Response().Header.Peek(HeaderETag)))
}) })