diff options
Diffstat (limited to 'app_test.go')
-rw-r--r-- | app_test.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app_test.go b/app_test.go index 3b476bdb..6da1e4fd 100644 --- a/app_test.go +++ b/app_test.go @@ -125,3 +125,21 @@ func TestHealthCheckMiddleware(t *testing.T) { }) } } + +func TestHandlePanicMiddleware(t *testing.T) { + next := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + panic("on purpose") + }) + + ww := httptest.NewRecorder() + rr := httptest.NewRequest(http.MethodGet, "https://gitlab.io", nil) + + handler := handlePanicMiddleware(next) + + handler.ServeHTTP(ww, rr) + + res := ww.Result() + res.Body.Close() + + require.Equal(t, http.StatusInternalServerError, res.StatusCode) +} |