Skip to content

Commit

Permalink
Update route_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
KlassnayaAfrodita authored Dec 26, 2024
1 parent ee526b3 commit 4d7e660
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 4d7e660

Please sign in to comment.