Chore: Move ReqContext to contexthandler service (#62102)

* Chore: Move ReqContext to contexthandler service

* Rename package to contextmodel

* Generate ngalert files

* Remove unused imports
This commit is contained in:
idafurjes
2023-01-27 08:50:36 +01:00
committed by GitHub
parent 8379a29b53
commit 6c5a573772
180 changed files with 1208 additions and 1182 deletions
+6 -6
View File
@@ -9,7 +9,7 @@ import (
"github.com/grafana/grafana/pkg/api/response"
"github.com/grafana/grafana/pkg/api/routing"
"github.com/grafana/grafana/pkg/models"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
"github.com/grafana/grafana/pkg/services/user"
"github.com/stretchr/testify/require"
)
@@ -17,7 +17,7 @@ import (
func TestServer(t *testing.T) {
routeRegister := routing.NewRouteRegister()
var actualRequest *http.Request
routeRegister.Post("/api", routing.Wrap(func(c *models.ReqContext) response.Response {
routeRegister.Post("/api", routing.Wrap(func(c *contextmodel.ReqContext) response.Response {
actualRequest = c.Req
return response.JSON(http.StatusOK, c.SignedInUser)
}))
@@ -68,7 +68,7 @@ func verifyRequest(t *testing.T, s *Server, req *http.Request, expectedBody stri
require.NotEmpty(t, requestIdentifierFromRequest(req))
req = RequestWithWebContext(req, &models.ReqContext{
req = RequestWithWebContext(req, &contextmodel.ReqContext{
IsSignedIn: true,
})
require.NotNil(t, req)
@@ -79,7 +79,7 @@ func verifyRequest(t *testing.T, s *Server, req *http.Request, expectedBody stri
func TestServerClient(t *testing.T) {
routeRegister := routing.NewRouteRegister()
routeRegister.Get("/test", routing.Wrap(func(c *models.ReqContext) response.Response {
routeRegister.Get("/test", routing.Wrap(func(c *contextmodel.ReqContext) response.Response {
return response.JSON(http.StatusOK, c.SignedInUser)
}))
@@ -87,7 +87,7 @@ func TestServerClient(t *testing.T) {
t.Run("Making a request with user 1 should return user 1 as signed in user", func(t *testing.T) {
req := s.NewRequest(http.MethodGet, "/test", nil)
req = RequestWithWebContext(req, &models.ReqContext{
req = RequestWithWebContext(req, &contextmodel.ReqContext{
SignedInUser: &user.SignedInUser{
UserID: 1,
},
@@ -109,7 +109,7 @@ func TestServerClient(t *testing.T) {
t.Run("Making a request with user 2 should return user 2 as signed in user", func(t *testing.T) {
req := s.NewRequest(http.MethodGet, "/test", nil)
req = RequestWithWebContext(req, &models.ReqContext{
req = RequestWithWebContext(req, &contextmodel.ReqContext{
SignedInUser: &user.SignedInUser{
UserID: 2,
},