Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix unhandled errors in app_test.go #2071

Merged
merged 24 commits into from Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fe7f105
fix unhandled errors
Kamandlou Aug 26, 2022
7f1028d
fix unhandled error in cache package test
Kamandlou Aug 26, 2022
bf387fa
omit variable type
Kamandlou Aug 26, 2022
d09213b
omit variable type
Kamandlou Aug 26, 2022
14b6646
rename variable because collide with the imported package name
Kamandlou Aug 26, 2022
1c45f7e
handle file error on closing
Kamandlou Aug 26, 2022
a021d0c
Merge branch 'gofiber:master' into master
Kamandlou Aug 26, 2022
89bf878
fix unhandled in common_linux.go
Kamandlou Aug 28, 2022
8dded84
Merge branch 'gofiber:master' into master
Kamandlou Aug 29, 2022
08a9256
fix unhandled errors in helpers_test.go
Kamandlou Aug 29, 2022
038315d
fix unhandled errors in listen_test.go
Kamandlou Aug 30, 2022
e5b8dad
remove unused parameter in emptyHandler method
Kamandlou Aug 30, 2022
92e6920
refactor path.go
Kamandlou Sep 1, 2022
3086fd2
unhandled error in hooks test
Kamandlou Sep 1, 2022
73c9987
Merge branch 'gofiber:master' into master
Kamandlou Sep 2, 2022
8b466c3
fix unhandled errors in app_test.go
Kamandlou Sep 2, 2022
f1f46b1
Merge pull request #1 from Kamandlou/dev
Kamandlou Sep 2, 2022
a125a5f
fix unhandled errors in ctx_test.go
Kamandlou Sep 2, 2022
d00514c
Merge pull request #2 from Kamandlou/dev
Kamandlou Sep 3, 2022
81a0bc5
✨ fix unhandled errors in helpers_test.go
Kamandlou Sep 4, 2022
9ba9001
Merge branch 'gofiber:master' into master
Kamandlou Sep 4, 2022
83885d6
Merge pull request #3 from Kamandlou/dev
Kamandlou Sep 4, 2022
cec4b83
revert app_test.go
Kamandlou Sep 5, 2022
02aa986
Merge pull request #4 from Kamandlou/dev
Kamandlou Sep 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion app_test.go
Expand Up @@ -1378,7 +1378,8 @@ func Test_App_New_Test_Parallel(t *testing.T) {
t.Run("Test_App_New_Test_Parallel_2", func(t *testing.T) {
t.Parallel()
app := New(Config{Immutable: true})
app.Test(httptest.NewRequest("GET", "/", nil))
_, err := app.Test(httptest.NewRequest("GET", "/", nil))
utils.AssertEqual(t, nil, err)
})
}

Expand Down
27 changes: 17 additions & 10 deletions ctx_test.go
Expand Up @@ -755,35 +755,42 @@ func Test_Ctx_Format(t *testing.T) {
c := app.AcquireCtx(&fasthttp.RequestCtx{})
defer app.ReleaseCtx(c)
c.Request().Header.Set(HeaderAccept, MIMETextPlain)
c.Format([]byte("Hello, World!"))
err := c.Format([]byte("Hello, World!"))
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "Hello, World!", string(c.Response().Body()))

c.Request().Header.Set(HeaderAccept, MIMETextHTML)
c.Format("Hello, World!")
err = c.Format("Hello, World!")
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "<p>Hello, World!</p>", string(c.Response().Body()))

c.Request().Header.Set(HeaderAccept, MIMEApplicationJSON)
c.Format("Hello, World!")
err = c.Format("Hello, World!")
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, `"Hello, World!"`, string(c.Response().Body()))

c.Request().Header.Set(HeaderAccept, MIMETextPlain)
c.Format(complex(1, 1))
err = c.Format(complex(1, 1))
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "(1+1i)", string(c.Response().Body()))

c.Request().Header.Set(HeaderAccept, MIMEApplicationXML)
c.Format("Hello, World!")
err = c.Format("Hello, World!")
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, `<string>Hello, World!</string>`, string(c.Response().Body()))

err := c.Format(complex(1, 1))
err = c.Format(complex(1, 1))
utils.AssertEqual(t, true, err != nil)

c.Request().Header.Set(HeaderAccept, MIMETextPlain)
c.Format(Map{})
err = c.Format(Map{})
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "map[]", string(c.Response().Body()))

type broken string
c.Request().Header.Set(HeaderAccept, "broken/accept")
c.Format(broken("Hello, World!"))
err = c.Format(broken("Hello, World!"))
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, `Hello, World!`, string(c.Response().Body()))
}

Expand Down Expand Up @@ -3137,8 +3144,8 @@ func Test_Ctx_Get_Location_From_Route_name(t *testing.T) {
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "/user/fiber", location)
})
t.Run("case sensitive",func(t *testing.T) {

t.Run("case sensitive", func(t *testing.T) {
app := New(Config{CaseSensitive: true})
c := app.AcquireCtx(&fasthttp.RequestCtx{})
defer app.ReleaseCtx(c)
Expand Down
9 changes: 6 additions & 3 deletions helpers_test.go
Expand Up @@ -84,7 +84,8 @@ func Test_Utils_ETag_Weak(t *testing.T) {
t.Run("Match Weak ETag", func(t *testing.T) {
c := app.AcquireCtx(&fasthttp.RequestCtx{})
defer app.ReleaseCtx(c)
c.SendString("Hello, World!")
err := c.SendString("Hello, World!")
utils.AssertEqual(t, nil, err)
c.Request().Header.Set(HeaderIfNoneMatch, `W/"13-1831710635"`)
setETag(c, true)
utils.AssertEqual(t, 304, c.Response().StatusCode())
Expand All @@ -95,7 +96,8 @@ func Test_Utils_ETag_Weak(t *testing.T) {
t.Run("Not Match Weak ETag", func(t *testing.T) {
c := app.AcquireCtx(&fasthttp.RequestCtx{})
defer app.ReleaseCtx(c)
c.SendString("Hello, World!")
err := c.SendString("Hello, World!")
utils.AssertEqual(t, nil, err)
c.Request().Header.Set(HeaderIfNoneMatch, `W/"13-1831710635xx"`)
setETag(c, true)
utils.AssertEqual(t, `W/"13-1831710635"`, string(c.Response().Header.Peek(HeaderETag)))
Expand Down Expand Up @@ -135,7 +137,8 @@ func Benchmark_Utils_ETag_Weak(b *testing.B) {
app := New()
c := app.AcquireCtx(&fasthttp.RequestCtx{})
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++ {
setETag(c, true)
}
Expand Down