From c8b1879b11d4f09fbba3fef9f741f9bc2f28db64 Mon Sep 17 00:00:00 2001 From: Amir Hossein <77993374+Kamandlou@users.noreply.github.com> Date: Mon, 5 Sep 2022 15:41:09 +0430 Subject: [PATCH] fix unhandled errors in app_test.go (#2071) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 * fix unhandled errors in listen_test.go * remove unused parameter in emptyHandler method * refactor path.go * unhandled error in hooks test * fix unhandled errors in app_test.go * fix unhandled errors in ctx_test.go * ✨ fix unhandled errors in helpers_test.go * revert app_test.go --- app_test.go | 3 ++- ctx_test.go | 27 +++++++++++++++++---------- helpers_test.go | 9 ++++++--- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/app_test.go b/app_test.go index fcb623bd..d186193a 100644 --- a/app_test.go +++ b/app_test.go @@ -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) }) } diff --git a/ctx_test.go b/ctx_test.go index 31f47e7a..caf03787 100644 --- a/ctx_test.go +++ b/ctx_test.go @@ -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, "
Hello, World!
", 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, `