mirror of
https://github.com/grafana/grafana.git
synced 2024-11-23 09:26:43 -06:00
fix error code for delete folder (#42470)
This commit is contained in:
parent
4e8b97b8ed
commit
e13e6a7bd7
@ -692,9 +692,15 @@ func (l *LibraryElementService) deleteLibraryElementsInFolderUID(c context.Conte
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(folderUIDs) == 0 {
|
||||
return models.ErrFolderNotFound
|
||||
}
|
||||
|
||||
if len(folderUIDs) != 1 {
|
||||
return fmt.Errorf("found %d folders, while expecting at most one", len(folderUIDs))
|
||||
}
|
||||
|
||||
folderID := folderUIDs[0].ID
|
||||
|
||||
if err := l.requirePermissionsOnFolder(c, signedInUser, folderID); err != nil {
|
||||
|
@ -67,6 +67,12 @@ func TestDeleteLibraryPanelsInFolder(t *testing.T) {
|
||||
require.EqualError(t, err, ErrFolderHasConnectedLibraryElements.Error())
|
||||
})
|
||||
|
||||
scenarioWithPanel(t, "When an admin tries to delete a folder uid that doesn't exist, it should fail",
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
err := sc.service.DeleteLibraryElementsInFolder(sc.reqContext.Req.Context(), sc.reqContext.SignedInUser, sc.folder.Uid+"xxxx")
|
||||
require.EqualError(t, err, models.ErrFolderNotFound.Error())
|
||||
})
|
||||
|
||||
scenarioWithPanel(t, "When an admin tries to delete a folder that contains disconnected elements, it should delete all disconnected elements too",
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
command := getCreateVariableCommand(sc.folder.Id, "query0")
|
||||
|
Loading…
Reference in New Issue
Block a user