mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 16:44:26 +00:00
819aed35bf
To mock a handler: ```go web.RouteMock(web.MockAfterMiddlewares, func(ctx *context.Context) { // ... }) defer web.RouteMockReset() ``` It helps: * Test the middleware's behavior (assert the ctx.Data, etc) * Mock the middleware's behavior (prepare some context data for handler) * Mock the handler's response for some test cases, especially for some integration tests and e2e tests. |
||
---|---|---|
.. | ||
middleware | ||
routing | ||
types | ||
handler.go | ||
route_test.go | ||
route.go | ||
routemock_test.go | ||
routemock.go |