Chore: Fix fetching the General folder when nested folders is set and improve error handling (#62951)

* Nested folders: Modify Get() not to fail fetching the General folder

* Add test
This commit is contained in:
Sofia Papagiannaki
2023-02-08 17:16:53 +02:00
committed by GitHub
parent 4181acec72
commit 225c8dbba7
3 changed files with 39 additions and 3 deletions
@@ -763,6 +763,32 @@ func TestNestedFolderService(t *testing.T) {
assert.ErrorIs(t, err, folder.ErrMaximumDepthReached)
require.NotNil(t, actualCmd)
})
t.Run("get default folder, no error", func(t *testing.T) {
g := guardian.New
guardian.MockDashboardGuardian(&guardian.FakeDashboardGuardian{CanSaveValue: true})
t.Cleanup(func() {
guardian.New = g
})
// dashboard store commands that should be called.
dashStore := &dashboards.FakeDashboardStore{}
dashboardFolderStore := foldertest.NewFakeFolderStore(t)
nestedFolderStore := NewFakeStore()
nestedFolderStore.ExpectedError = folder.ErrFolderNotFound
folderSvc := setup(t, dashStore, dashboardFolderStore, nestedFolderStore, featuremgmt.WithFeatures("nestedFolders"), actest.FakeAccessControl{
ExpectedEvaluate: true,
})
_, err := folderSvc.Get(context.Background(), &folder.GetFolderQuery{
OrgID: orgID,
ID: &folder.GeneralFolder.ID,
SignedInUser: usr,
})
require.NoError(t, err)
})
})
}