package server_test import ( "context" "net/http" "net/http/httptest" "net/url" "strconv" "testing" "github.com/getsentry/sentry-go" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "sneak.berlin/go/webhooker/internal/config" "sneak.berlin/go/webhooker/internal/server" ) // The link back the error page offers: to the webhook list for a // signed-in user, to sign-in for anyone else. const ( backToWebhooks = `` + `Back to webhooks` backToSignIn = `` + `Sign in` ) // assertErrorPage checks that w is the error page for status, in the // normal layout, offering link. func assertErrorPage( t *testing.T, w *httptest.ResponseRecorder, status int, link string, ) { t.Helper() body := w.Body.String() assert.Equal(t, status, w.Code) assert.Equal( t, "text/html; charset=utf-8", w.Header().Get("Content-Type"), ) assert.Equal(t, "no-store", w.Header().Get("Cache-Control")) assert.Contains(t, body, `