chore(services): replace dependencies on dashboard store with dashboard service (#63937)

* chore(services): replace dependencies on dashboard store with dashboard service

This continues the backend service/store split by replacing dashboard store dependencies with service dependencies. the folder service remains the single exception for now; otherwise we'd have a dependency cycle between the folder and dashboard services. I have some ideas for that, but I'll take care of all the easy parts first.

While doing this, I identified and removed a number of unused arguments from the following functions:

NewFolderNameScopeResolver
NewFolderIDScopeResolver
NewFolderUIDScopeResolver
NewDashboardIDScopeResolver
NewDashboardUIDScopeResolver
resolveDashboardScope

I have a small enterprise PR to support this commit.

* lingering fmt
This commit is contained in:
Kristin Laemmert
2023-03-02 08:09:57 -05:00
committed by GitHub
parent a227f69bed
commit bb798e24f3
13 changed files with 120 additions and 170 deletions

View File

@@ -25,13 +25,13 @@ func TestDashboardService(t *testing.T) {
fakeStore := dashboards.FakeDashboardStore{}
defer fakeStore.AssertExpectations(t)
folderStore := foldertest.NewFakeFolderStore(t)
folderSvc := foldertest.NewFakeService()
service := &DashboardServiceImpl{
cfg: setting.NewCfg(),
log: log.New("test.logger"),
dashboardStore: &fakeStore,
folderStore: folderStore,
folderService: folderSvc,
dashAlertExtractor: &dummyDashAlertExtractor{},
}
@@ -230,13 +230,11 @@ func TestDashboardService(t *testing.T) {
})
t.Run("Count dashboards in folder", func(t *testing.T) {
folderStore.On("GetFolderByUID", mock.Anything, mock.AnythingOfType("int64"), mock.AnythingOfType("string")).Return(&folder.Folder{}, nil)
fakeStore.On("CountDashboardsInFolder", mock.Anything, mock.AnythingOfType("*dashboards.CountDashboardsInFolderRequest")).Return(int64(3), nil)
folderSvc.ExpectedFolder = &folder.Folder{ID: 1}
// set up a ctx with signed in user
ctx := context.Background()
usr := &user.SignedInUser{UserID: 1}
ctx = appcontext.WithUser(ctx, usr)
ctx := appcontext.WithUser(context.Background(), usr)
count, err := service.CountDashboardsInFolder(ctx, &dashboards.CountDashboardsInFolderQuery{FolderUID: "i am a folder"})
require.NoError(t, err)