mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
API: return resource ID when deleting datasource with UID and library element (#41342)
* API: return resource ID when deleting datasource and library element * keep status codes consistent * fix element ID * add test * improve response struct * update endpoints documentation * LibraryElementIDResponse -> DeleteLibraryElementResponse
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package libraryelements
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||
@@ -17,11 +18,17 @@ func TestDeleteLibraryElement(t *testing.T) {
|
||||
require.Equal(t, 404, resp.Status())
|
||||
})
|
||||
|
||||
scenarioWithPanel(t, "When an admin tries to delete a library panel that exists, it should succeed",
|
||||
scenarioWithPanel(t, "When an admin tries to delete a library panel that exists, it should succeed and return correct ID",
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
sc.ctx.Req = web.SetURLParams(sc.ctx.Req, map[string]string{":uid": sc.initialResult.Result.UID})
|
||||
resp := sc.service.deleteHandler(sc.reqContext)
|
||||
require.Equal(t, 200, resp.Status())
|
||||
|
||||
var result DeleteLibraryElementResponse
|
||||
err := json.Unmarshal(resp.Body(), &result)
|
||||
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, sc.initialResult.Result.ID, result.ID)
|
||||
})
|
||||
|
||||
scenarioWithPanel(t, "When an admin tries to delete a library panel in another org, it should fail",
|
||||
|
||||
Reference in New Issue
Block a user