mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-13 16:09:48 +08: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 |