Commit Graph

1 Commits (cad22512b8948fa52e1684ec30bb5a6e5d427d5f)

Author SHA1 Message Date
wxiaoguang 819aed35bf
Make route middleware/handler mockable ()
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.