mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 18:32:23 +08:00
Chore: Deprecate FolderID in PatchLibraryElementCommand (#77472)
* Chore: Deprecate FolderID in PatchLibraryElementCommand * chore: regen specs
This commit is contained in:
@ -26,7 +26,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
newFolder := createFolder(t, sc, "NewFolder")
|
||||
cmd := model.PatchLibraryElementCommand{
|
||||
FolderID: newFolder.ID,
|
||||
FolderID: newFolder.ID, // nolint:staticcheck
|
||||
Name: "Panel - New name",
|
||||
Model: []byte(`
|
||||
{
|
||||
@ -91,7 +91,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
newFolder := createFolder(t, sc, "NewFolder")
|
||||
cmd := model.PatchLibraryElementCommand{
|
||||
FolderID: newFolder.ID,
|
||||
FolderID: newFolder.ID, // nolint:staticcheck
|
||||
Kind: int64(model.PanelElement),
|
||||
Version: 1,
|
||||
}
|
||||
@ -115,7 +115,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
||||
scenarioWithPanel(t, "When an admin tries to patch a library panel with name only, it should change name successfully and return correct result",
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
cmd := model.PatchLibraryElementCommand{
|
||||
FolderID: -1,
|
||||
FolderID: -1, // nolint:staticcheck
|
||||
Name: "New Name",
|
||||
Kind: int64(model.PanelElement),
|
||||
Version: 1,
|
||||
@ -138,7 +138,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
||||
scenarioWithPanel(t, "When an admin tries to patch a library panel with a nonexistent UID, it should change UID successfully and return correct result",
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
cmd := model.PatchLibraryElementCommand{
|
||||
FolderID: -1,
|
||||
FolderID: -1, // nolint:staticcheck
|
||||
UID: util.GenerateShortUID(),
|
||||
Kind: int64(model.PanelElement),
|
||||
Version: 1,
|
||||
@ -161,7 +161,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
||||
scenarioWithPanel(t, "When an admin tries to patch a library panel with an invalid UID, it should fail",
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
cmd := model.PatchLibraryElementCommand{
|
||||
FolderID: -1,
|
||||
FolderID: -1, // nolint:staticcheck
|
||||
UID: "Testing an invalid UID",
|
||||
Kind: int64(model.PanelElement),
|
||||
Version: 1,
|
||||
@ -175,7 +175,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
||||
scenarioWithPanel(t, "When an admin tries to patch a library panel with an UID that is too long, it should fail",
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
cmd := model.PatchLibraryElementCommand{
|
||||
FolderID: -1,
|
||||
FolderID: -1, // nolint:staticcheck
|
||||
UID: "j6T00KRZzj6T00KRZzj6T00KRZzj6T00KRZzj6T00K",
|
||||
Kind: int64(model.PanelElement),
|
||||
Version: 1,
|
||||
@ -194,7 +194,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
||||
resp := sc.service.createHandler(sc.reqContext)
|
||||
require.Equal(t, 200, resp.Status())
|
||||
cmd := model.PatchLibraryElementCommand{
|
||||
FolderID: -1,
|
||||
FolderID: -1, // nolint:staticcheck
|
||||
UID: command.UID,
|
||||
Kind: int64(model.PanelElement),
|
||||
Version: 1,
|
||||
@ -208,7 +208,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
||||
scenarioWithPanel(t, "When an admin tries to patch a library panel with model only, it should change model successfully, sync type and description fields and return correct result",
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
cmd := model.PatchLibraryElementCommand{
|
||||
FolderID: -1,
|
||||
FolderID: -1, // nolint:staticcheck
|
||||
Model: []byte(`{ "title": "New Model Title", "name": "New Model Name", "type":"graph", "description": "New description" }`),
|
||||
Kind: int64(model.PanelElement),
|
||||
Version: 1,
|
||||
@ -237,7 +237,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
||||
scenarioWithPanel(t, "When an admin tries to patch a library panel with model.description only, it should change model successfully, sync type and description fields and return correct result",
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
cmd := model.PatchLibraryElementCommand{
|
||||
FolderID: -1,
|
||||
FolderID: -1, // nolint:staticcheck
|
||||
Model: []byte(`{ "description": "New description" }`),
|
||||
Kind: int64(model.PanelElement),
|
||||
Version: 1,
|
||||
@ -264,7 +264,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
||||
scenarioWithPanel(t, "When an admin tries to patch a library panel with model.type only, it should change model successfully, sync type and description fields and return correct result",
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
cmd := model.PatchLibraryElementCommand{
|
||||
FolderID: -1,
|
||||
FolderID: -1, // nolint:staticcheck
|
||||
Model: []byte(`{ "type": "graph" }`),
|
||||
Kind: int64(model.PanelElement),
|
||||
Version: 1,
|
||||
@ -290,6 +290,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
||||
|
||||
scenarioWithPanel(t, "When another admin tries to patch a library panel, it should change UpdatedBy successfully and return correct result",
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
// nolint:staticcheck
|
||||
cmd := model.PatchLibraryElementCommand{FolderID: -1, Version: 1, Kind: int64(model.PanelElement)}
|
||||
sc.reqContext.UserID = 2
|
||||
sc.ctx.Req = web.SetURLParams(sc.ctx.Req, map[string]string{":uid": sc.initialResult.Result.UID})
|
||||
@ -331,7 +332,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
||||
resp := sc.service.createHandler(sc.reqContext)
|
||||
var result = validateAndUnMarshalResponse(t, resp)
|
||||
cmd := model.PatchLibraryElementCommand{
|
||||
FolderID: 1,
|
||||
FolderID: 1, // nolint:staticcheck
|
||||
Version: 1,
|
||||
Kind: int64(model.PanelElement),
|
||||
}
|
||||
@ -344,7 +345,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
||||
scenarioWithPanel(t, "When an admin tries to patch a library panel in another org, it should fail",
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
cmd := model.PatchLibraryElementCommand{
|
||||
FolderID: sc.folder.ID,
|
||||
FolderID: sc.folder.ID, // nolint:staticcheck
|
||||
Version: 1,
|
||||
Kind: int64(model.PanelElement),
|
||||
}
|
||||
@ -358,7 +359,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
||||
scenarioWithPanel(t, "When an admin tries to patch a library panel with an old version number, it should fail",
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
cmd := model.PatchLibraryElementCommand{
|
||||
FolderID: sc.folder.ID,
|
||||
FolderID: sc.folder.ID, // nolint:staticcheck
|
||||
Version: 1,
|
||||
Kind: int64(model.PanelElement),
|
||||
}
|
||||
@ -374,7 +375,7 @@ func TestPatchLibraryElement(t *testing.T) {
|
||||
scenarioWithPanel(t, "When an admin tries to patch a library panel with an other kind, it should succeed but panel should not change",
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
cmd := model.PatchLibraryElementCommand{
|
||||
FolderID: sc.folder.ID,
|
||||
FolderID: sc.folder.ID, // nolint:staticcheck
|
||||
Version: 1,
|
||||
Kind: int64(model.VariableElement),
|
||||
}
|
||||
|
Reference in New Issue
Block a user