Nested folders: Fix delete (#59627)

* Fix deleting subfolder

It used to fail with beause of missing signed in user

* Add logging

* fixup

* Fail request if deleting nested folder has failed

Before we only used to log the error

* Fix failing test

During failed nested folder creation
call the dashboard store deletion instead of the service one.
This commit is contained in:
Sofia Papagiannaki
2022-12-01 05:27:40 -05:00
committed by GitHub
parent 8ed2426e8e
commit 798a8ceb9c
2 changed files with 16 additions and 3 deletions
@@ -476,6 +476,10 @@ func TestNestedFolderService(t *testing.T) {
dashStore.On("SaveDashboard", mock.Anything, mock.AnythingOfType("models.SaveDashboardCommand")).Return(&models.Dashboard{}, nil)
dashStore.On("GetFolderByID", mock.Anything, mock.AnythingOfType("int64"), mock.AnythingOfType("int64")).Return(&folder.Folder{}, nil)
dashStore.On("GetFolderByUID", mock.Anything, mock.AnythingOfType("int64"), mock.AnythingOfType("string")).Return(&folder.Folder{}, nil)
var actualCmd *models.DeleteDashboardCommand
dashStore.On("DeleteDashboard", mock.Anything, mock.Anything).Run(func(args mock.Arguments) {
actualCmd = args.Get(1).(*models.DeleteDashboardCommand)
}).Return(nil).Once()
// return an error from the folder store
store.ExpectedError = errors.New("FAILED")
@@ -491,6 +495,7 @@ func TestNestedFolderService(t *testing.T) {
// CreateFolder should also call the folder store's create method.
require.True(t, store.CreateCalled)
require.NotNil(t, actualCmd)
t.Cleanup(func() {
guardian.New = g