Plugins: Refactor GetPluginDashboards/LoadPluginDashboard (#46316)
Refactors GetPluginDashboards/LoadPluginDashboard by moving database interaction from plugin management to the plugindashboards service. Fixes #44553 Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
This commit is contained in:
co-authored by
Will Browne
parent
d076cabb60
commit
6c7d326499
@@ -49,6 +49,16 @@ func NewServer(t testing.TB, routeRegister routing.RouteRegister) *Server {
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetRequest creates a new GET request setup for test.
|
||||
func (s *Server) NewGetRequest(target string) *http.Request {
|
||||
return s.NewRequest(http.MethodGet, target, nil)
|
||||
}
|
||||
|
||||
// NewPostRequest creates a new POST request setup for test.
|
||||
func (s *Server) NewPostRequest(target string, body io.Reader) *http.Request {
|
||||
return s.NewRequest(http.MethodPost, target, body)
|
||||
}
|
||||
|
||||
// NewRequest creates a new request setup for test.
|
||||
func (s *Server) NewRequest(method string, target string, body io.Reader) *http.Request {
|
||||
s.t.Helper()
|
||||
@@ -65,11 +75,19 @@ func (s *Server) NewRequest(method string, target string, body io.Reader) *http.
|
||||
return req
|
||||
}
|
||||
|
||||
// Send sends an HTTP request to the test server and returns an HTTP response
|
||||
// Send sends a HTTP request to the test server and returns an HTTP response.
|
||||
func (s *Server) Send(req *http.Request) (*http.Response, error) {
|
||||
return http.DefaultClient.Do(req)
|
||||
}
|
||||
|
||||
// SendJSON sets the Content-Type header to application/json and sends
|
||||
// a HTTP request to the test server and returns an HTTP response.
|
||||
// Suitable for POST/PUT/PATCH requests that sends request body as JSON.
|
||||
func (s *Server) SendJSON(req *http.Request) (*http.Response, error) {
|
||||
req.Header.Add("Content-Type", "application/json")
|
||||
return s.Send(req)
|
||||
}
|
||||
|
||||
func generateRequestIdentifier() string {
|
||||
return uuid.NewString()
|
||||
}
|
||||
@@ -91,7 +109,7 @@ func RequestWithWebContext(req *http.Request, c *models.ReqContext) *http.Reques
|
||||
|
||||
func RequestWithSignedInUser(req *http.Request, user *models.SignedInUser) *http.Request {
|
||||
return RequestWithWebContext(req, &models.ReqContext{
|
||||
SignedInUser: &models.SignedInUser{},
|
||||
SignedInUser: user,
|
||||
IsSignedIn: true,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user