Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-26 03:36:10 +01:00

Partial cherry-pick: a4859dcfea Improve user experience for outdated comments (#29050)

This commit is contained in:
Earl Warren 2024-03-04 11:38:52 +08:00
parent ff8f7a7a0d
commit cfce4e089e
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -40,8 +40,19 @@ func mockRequest(t *testing.T, reqPath string) *http.Request {
return req
}
type MockContextOption struct {
Render context.Render
}
// MockContext mock context for unit tests
func MockContext(t *testing.T, reqPath string) (*context.Context, *httptest.ResponseRecorder) {
func MockContext(t *testing.T, reqPath string, opts ...MockContextOption) (*context.Context, *httptest.ResponseRecorder) {
var opt MockContextOption
if len(opts) > 0 {
opt = opts[0]
}
if opt.Render == nil {
opt.Render = &MockRender{}
}
resp := httptest.NewRecorder()
req := mockRequest(t, reqPath)
base, baseCleanUp := context.NewBaseContext(resp, req)