mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 04:04:00 -06:00
a21a232a8e
* Revert "chore: add replDB to team service (#91799)" This reverts commitc6ae2d7999
. * Revert "experiment: use read replica for Get and Find Dashboards (#91706)" This reverts commit54177ca619
. * Revert "QuotaService: refactor to use ReplDB for Get queries (#91333)" This reverts commit299c142f6a
. * Revert "refactor replCfg to look more like plugins/plugin config (#91142)" This reverts commitac0b4bb34d
. * Revert "chore (replstore): fix registration with multiple sql drivers, again (#90990)" This reverts commitdaedb358dd
. * Revert "Chore (sqlstore): add validation and testing for repl config (#90683)" This reverts commitaf19f039b6
. * Revert "ReplStore: Add support for round robin load balancing between multiple read replicas (#90530)" This reverts commit27b52b1507
. * Revert "DashboardStore: Use ReplDB and get dashboard quotas from the ReadReplica (#90235)" This reverts commit8a6107cd35
. * Revert "accesscontrol service read replica (#89963)" This reverts commit77a4869fca
. * Revert "Fix: add mapping for the new mysqlRepl driver (#89551)" This reverts commitab5a079bcc
. * Revert "fix: sql instrumentation dual registration error (#89508)" This reverts commitd988f5c3b0
. * Revert "Experimental Feature Toggle: databaseReadReplica (#89232)" This reverts commit50244ed4a1
.
67 lines
2.7 KiB
Go
67 lines
2.7 KiB
Go
package testutil
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/mock"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/grafana/grafana/pkg/bus"
|
|
"github.com/grafana/grafana/pkg/infra/db"
|
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
|
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
|
acmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
|
|
"github.com/grafana/grafana/pkg/services/dashboards"
|
|
"github.com/grafana/grafana/pkg/services/dashboards/database"
|
|
dashboardservice "github.com/grafana/grafana/pkg/services/dashboards/service"
|
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
|
"github.com/grafana/grafana/pkg/services/folder"
|
|
"github.com/grafana/grafana/pkg/services/folder/folderimpl"
|
|
"github.com/grafana/grafana/pkg/services/folder/foldertest"
|
|
"github.com/grafana/grafana/pkg/services/guardian"
|
|
"github.com/grafana/grafana/pkg/services/quota/quotatest"
|
|
"github.com/grafana/grafana/pkg/services/supportbundles/supportbundlestest"
|
|
"github.com/grafana/grafana/pkg/services/tag/tagimpl"
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
)
|
|
|
|
func SetupFolderService(tb testing.TB, cfg *setting.Cfg, db db.DB, dashboardStore dashboards.Store, folderStore *folderimpl.DashboardFolderStoreImpl, bus *bus.InProcBus, features featuremgmt.FeatureToggles, ac accesscontrol.AccessControl) folder.Service {
|
|
tb.Helper()
|
|
return folderimpl.ProvideService(ac, bus, dashboardStore, folderStore, db, features, supportbundlestest.NewFakeBundleService(), nil, tracing.InitializeTracerForTest())
|
|
}
|
|
|
|
func SetupDashboardService(tb testing.TB, sqlStore db.DB, fs *folderimpl.DashboardFolderStoreImpl, cfg *setting.Cfg) (*dashboardservice.DashboardServiceImpl, dashboards.Store) {
|
|
tb.Helper()
|
|
|
|
origNewGuardian := guardian.New
|
|
guardian.MockDashboardGuardian(&guardian.FakeDashboardGuardian{
|
|
CanSaveValue: true,
|
|
CanViewValue: true,
|
|
CanAdminValue: true,
|
|
})
|
|
tb.Cleanup(func() {
|
|
guardian.New = origNewGuardian
|
|
})
|
|
|
|
ac := acmock.New()
|
|
dashboardPermissions := acmock.NewMockedPermissionsService()
|
|
folderPermissions := acmock.NewMockedPermissionsService()
|
|
folderPermissions.On("SetPermissions", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return([]accesscontrol.ResourcePermission{}, nil)
|
|
|
|
features := featuremgmt.WithFeatures()
|
|
quotaService := quotatest.New(false, nil)
|
|
|
|
dashboardStore, err := database.ProvideDashboardStore(sqlStore, cfg, features, tagimpl.ProvideService(sqlStore), quotaService)
|
|
require.NoError(tb, err)
|
|
|
|
dashboardService, err := dashboardservice.ProvideDashboardServiceImpl(
|
|
cfg, dashboardStore, fs,
|
|
features, folderPermissions, dashboardPermissions, ac,
|
|
foldertest.NewFakeService(),
|
|
nil,
|
|
)
|
|
require.NoError(tb, err)
|
|
|
|
return dashboardService, dashboardStore
|
|
}
|