mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-04-24 08:36:20 +00:00
- Massive replacement of changing `code.gitea.io/gitea` to `forgejo.org`. - Resolves forgejo/discussions#258 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7337 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Reviewed-by: Beowulf <beowulf@beocode.eu> Reviewed-by: Panagiotis "Ivory" Vasilopoulos <git@n0toose.net> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package common
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"net/url"
|
|
"testing"
|
|
|
|
"forgejo.org/models/unittest"
|
|
"forgejo.org/modules/test"
|
|
"forgejo.org/modules/web/middleware"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestRenderPanicErrorPage(t *testing.T) {
|
|
w := httptest.NewRecorder()
|
|
req := &http.Request{URL: &url.URL{}}
|
|
req = req.WithContext(middleware.WithContextData(t.Context()))
|
|
RenderPanicErrorPage(w, req, errors.New("fake panic error (for test only)"))
|
|
respContent := w.Body.String()
|
|
assert.Contains(t, respContent, `class="page-content status-page-500"`)
|
|
assert.Contains(t, respContent, `</html>`)
|
|
assert.Contains(t, respContent, `lang="en-US"`) // make sure the locale work
|
|
|
|
// the 500 page doesn't have normal pages footer, it makes it easier to distinguish a normal page and a failed page.
|
|
// especially when a sub-template causes page error, the HTTP response code is still 200,
|
|
// the different "footer" is the only way to know whether a page is fully rendered without error.
|
|
assert.False(t, test.IsNormalPageCompleted(respContent))
|
|
}
|
|
|
|
func TestMain(m *testing.M) {
|
|
unittest.MainTest(m)
|
|
}
|