forked from forgejo/forgejo
[TESTS] testMiddlewareHook, dependency injection in integration tests
(cherry picked from commit6623630d10
) (cherry picked from commitd30b9dc5b4
) (cherry picked from commit8e790a65ba
) (cherry picked from commit9d98ba7e5c
) (cherry picked from commit07fc55a3a7
)
This commit is contained in:
parent
94a458835a
commit
f9d054d17f
6 changed files with 28 additions and 19 deletions
|
@ -40,7 +40,19 @@ import (
|
|||
"github.com/xeipuuv/gojsonschema"
|
||||
)
|
||||
|
||||
var c *web.Route
|
||||
var (
|
||||
c *web.Route
|
||||
testMiddlewareHook func(*gitea_context.Context)
|
||||
)
|
||||
|
||||
func setNormalRoutes() {
|
||||
middlewareHook := func(ctx *gitea_context.Context) {
|
||||
if testMiddlewareHook != nil {
|
||||
testMiddlewareHook(ctx)
|
||||
}
|
||||
}
|
||||
c = routers.NormalRoutes(middlewareHook)
|
||||
}
|
||||
|
||||
type NilResponseRecorder struct {
|
||||
httptest.ResponseRecorder
|
||||
|
@ -87,8 +99,7 @@ func TestMain(m *testing.M) {
|
|||
defer cancel()
|
||||
|
||||
tests.InitTest(true)
|
||||
c = routers.NormalRoutes()
|
||||
|
||||
setNormalRoutes()
|
||||
// integration test settings...
|
||||
if setting.CfgProvider != nil {
|
||||
testingCfg := setting.CfgProvider.Section("integration-tests")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue