Folder name scope resolver (#46380)

* move dashboard store mock to parent package to avoid cycle of dependencies
* add scope resolver for folders that resolves names to id
This commit is contained in:
Yuriy Tseretyan
2022-03-10 12:19:50 -05:00
committed by GitHub
parent 5a5def6de7
commit d076cabb60
13 changed files with 147 additions and 35 deletions

View File

@@ -8,6 +8,8 @@ import (
"time"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/require"
"github.com/grafana/grafana/pkg/api/routing"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/models"
@@ -20,7 +22,6 @@ import (
"github.com/grafana/grafana/pkg/services/libraryelements"
"github.com/grafana/grafana/pkg/services/sqlstore"
"github.com/grafana/grafana/pkg/setting"
"github.com/stretchr/testify/require"
)
const userInDbName = "user_in_db"
@@ -1439,7 +1440,8 @@ func createFolderWithACL(t *testing.T, sqlStore *sqlstore.SQLStore, title string
permissionsServices := acmock.NewPermissionsServicesMock()
dashboardStore := database.ProvideDashboardStore(sqlStore)
d := dashboardservice.ProvideDashboardService(cfg, dashboardStore, nil, features, permissionsServices)
s := dashboardservice.ProvideFolderService(cfg, d, dashboardStore, nil, features, permissionsServices)
ac := acmock.New()
s := dashboardservice.ProvideFolderService(cfg, d, dashboardStore, nil, features, permissionsServices, ac)
t.Logf("Creating folder with title and UID %q", title)
folder, err := s.CreateFolder(context.Background(), user, user.OrgId, title, title)
@@ -1536,9 +1538,11 @@ func testScenario(t *testing.T, desc string, fn func(t *testing.T, sc scenarioCo
cfg, dashboardStore, &alerting.DashAlertExtractorService{},
features, permissionsServices,
)
ac := acmock.New()
folderService := dashboardservice.ProvideFolderService(
cfg, dashboardService, dashboardStore, nil,
features, permissionsServices,
features, permissionsServices, ac,
)
elementService := libraryelements.ProvideService(cfg, sqlStore, routing.NewRouteRegister(), folderService)