Chore: Add context to org users (#39526)
* Add context to org users * Fix go lint * Roll back xorm refactor * Use WithTransactionalDbSession * Update sqlstore.go Fix typo * Update org_users.go Fix typo
This commit is contained in:
+11
-1
@@ -1,6 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@@ -45,6 +46,10 @@ func loggedInUserScenarioWithRole(t *testing.T, desc string, method string, url
|
||||
return sc.handlerFunc(sc.context)
|
||||
}
|
||||
|
||||
if sc.handlerFuncCtx != nil {
|
||||
return sc.handlerFuncCtx(context.Background(), sc.context)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -70,6 +75,10 @@ func anonymousUserScenario(t *testing.T, desc string, method string, url string,
|
||||
return sc.handlerFunc(sc.context)
|
||||
}
|
||||
|
||||
if sc.handlerFuncCtx != nil {
|
||||
return sc.handlerFuncCtx(context.Background(), sc.context)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -109,7 +118,6 @@ func (sc *scenarioContext) fakeReqWithParams(method, url string, queryParams map
|
||||
}
|
||||
req.URL.RawQuery = q.Encode()
|
||||
sc.req = req
|
||||
|
||||
return sc
|
||||
}
|
||||
|
||||
@@ -140,6 +148,7 @@ type scenarioContext struct {
|
||||
context *models.ReqContext
|
||||
resp *httptest.ResponseRecorder
|
||||
handlerFunc handlerFunc
|
||||
handlerFuncCtx handlerFuncCtx
|
||||
defaultHandler macaron.Handler
|
||||
req *http.Request
|
||||
url string
|
||||
@@ -152,6 +161,7 @@ func (sc *scenarioContext) exec() {
|
||||
|
||||
type scenarioFunc func(c *scenarioContext)
|
||||
type handlerFunc func(c *models.ReqContext) response.Response
|
||||
type handlerFuncCtx func(ctx context.Context, c *models.ReqContext) response.Response
|
||||
|
||||
func getContextHandler(t *testing.T, cfg *setting.Cfg) *contexthandler.ContextHandler {
|
||||
t.Helper()
|
||||
|
||||
Reference in New Issue
Block a user