mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
committed by
GitHub
parent
d076cabb60
commit
6c7d326499
@@ -40,6 +40,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/mockstore"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
"github.com/grafana/grafana/pkg/web/webtest"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -446,3 +447,31 @@ func mockRequestBody(v interface{}) io.ReadCloser {
|
||||
b, _ := json.Marshal(v)
|
||||
return io.NopCloser(bytes.NewReader(b))
|
||||
}
|
||||
|
||||
// APITestServerOption option func for customizing HTTPServer configuration
|
||||
// when setting up an API test server via SetupAPITestServer.
|
||||
type APITestServerOption func(hs *HTTPServer)
|
||||
|
||||
// SetupAPITestServer sets up a webtest.Server ready for testing all
|
||||
// routes registered via HTTPServer.registerRoutes().
|
||||
// Optionally customize HTTPServer configuration by providing APITestServerOption
|
||||
// option(s).
|
||||
func SetupAPITestServer(t *testing.T, opts ...APITestServerOption) *webtest.Server {
|
||||
t.Helper()
|
||||
|
||||
hs := &HTTPServer{
|
||||
RouteRegister: routing.NewRouteRegister(),
|
||||
Cfg: setting.NewCfg(),
|
||||
AccessControl: accesscontrolmock.New().WithDisabled(),
|
||||
Features: featuremgmt.WithFeatures(),
|
||||
searchUsersService: &searchusers.OSSService{},
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
opt(hs)
|
||||
}
|
||||
|
||||
hs.registerRoutes()
|
||||
s := webtest.NewServer(t, hs.RouteRegister)
|
||||
return s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user