mirror of
https://github.com/go-gitea/gitea
synced 2024-12-27 05:24:34 +01: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.go | ||
route_test.go | ||
routemock.go | ||
routemock_test.go |