From 4d7e660c71683135ef10ee75a5526fd107ef7ec7 Mon Sep 17 00:00:00 2001 From: Evgeny <113383200+KlassnayaAfrodita@users.noreply.github.com> Date: Thu, 26 Dec 2024 04:16:52 +0300 Subject: [PATCH] Update route_test.go --- route_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/route_test.go b/route_test.go index a77b01d..dc9bcd9 100644 --- a/route_test.go +++ b/route_test.go @@ -51,6 +51,29 @@ func TestRecoverWithCustomCallback(t *testing.T) { mockConfig.AssertExpectations(t) } +func TestRecoverWithDefaultCallback(t *testing.T) { + mockConfig := configmocks.NewConfig(t) + mockConfig.EXPECT().GetBool("app.debug").Return(true).Once() + mockConfig.EXPECT().GetInt("http.drivers.gin.body_limit", 4096).Return(4096).Once() + + w := httptest.NewRecorder() + req, _ := http.NewRequest("GET", "/recover", nil) + + route, err := NewRoute(mockConfig, nil) + assert.Nil(t, err) + + route.Get("/recover", func(ctx contractshttp.Context) contractshttp.Response { + panic(1) + }) + + route.ServeHTTP(w, req) + + assert.Equal(t, "", w.Body.String()) + assert.Equal(t, http.StatusInternalServerError, w.Code) + + mockConfig.AssertExpectations(t) +} + func TestFallback(t *testing.T) { mockConfig := &configmocks.Config{} mockConfig.EXPECT().GetBool("app.debug").Return(true).Once()