Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaime Martinez <jmartinez@gitlab.com>2021-10-07 07:28:15 +0300
committerVladimir Shushlin <v.shushlin@gmail.com>2021-10-14 14:32:38 +0300
commit98e38acc90217a7a5bdb23b048c10d47d6dee1f7 (patch)
treea73354f15d6598470df83e95fbf87f83eb5f06c6 /app_test.go
parent7e8f58590804c78f2c27f51212781d50bb1321ed (diff)
feat: add panic handler middleware
Changelog: added
Diffstat (limited to 'app_test.go')
-rw-r--r--app_test.go18
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)
+}