feat(nested folders): add CountDashboardsInFolder (#57847)

* feat(nested folders): add CountDashboardsInFolder

This commit adds a new method to the Dashboard service and stores: CountDashboardsInFolder. The command struct takes a folderUID, but the store implementation still depends on the parent folder ID. This is temporary; eventually we will replace all references to FolderIDs (associated with Dashboards) with folder UIDs.

There are some unfortunate additional test changes that were necessary after generating the service & store mocks; it looks like that hasn't been generated since the last change(s).

* more test updates
* don't forget the service test
* that didn't end up used, so bye for now
* agree to disagree with the linter
This commit is contained in:
Kristin Laemmert
2022-11-02 09:15:50 -04:00
committed by GitHub
parent 409ed84136
commit 706b301285
14 changed files with 271 additions and 118 deletions
@@ -560,6 +560,22 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
require.Equal(t, len(res), 1)
require.Equal(t, res[0].Title, "starred dash")
})
t.Run("Can count dashboards by parent folder", func(t *testing.T) {
setup()
// setup() saves one dashboard in the general folder and two in the "savedFolder".
count, err := dashboardStore.CountDashboardsInFolder(
context.Background(),
&dashboards.CountDashboardsInFolderRequest{FolderID: 0, OrgID: 1})
require.NoError(t, err)
require.Equal(t, int64(1), count)
count, err = dashboardStore.CountDashboardsInFolder(
context.Background(),
&dashboards.CountDashboardsInFolderRequest{FolderID: savedFolder.Id, OrgID: 1})
require.NoError(t, err)
require.Equal(t, int64(2), count)
})
}
func TestIntegrationDashboardDataAccessGivenPluginWithImportedDashboards(t *testing.T) {