mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: use any rather than interface{} (#74066)
This commit is contained in:
@@ -48,27 +48,27 @@ const userInDbAvatar = "/avatar/402d08de060496d6b6874495fe20f5ad"
|
||||
func TestConnectLibraryPanelsForDashboard(t *testing.T) {
|
||||
scenarioWithLibraryPanel(t, "When an admin tries to store a dashboard with a library panel, it should connect the two",
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
dashJSON := map[string]interface{}{
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
dashJSON := map[string]any{
|
||||
"panels": []any{
|
||||
map[string]any{
|
||||
"id": int64(1),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
map[string]any{
|
||||
"id": int64(2),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 6,
|
||||
"y": 0,
|
||||
},
|
||||
"datasource": "${DS_GDEV-TESTDATA}",
|
||||
"libraryPanel": map[string]interface{}{
|
||||
"libraryPanel": map[string]any{
|
||||
"uid": sc.initialResult.Result.UID,
|
||||
},
|
||||
"title": "Text - Library Panel",
|
||||
@@ -109,20 +109,20 @@ func TestConnectLibraryPanelsForDashboard(t *testing.T) {
|
||||
}
|
||||
outsidePanel, err := sc.elementService.CreateElement(sc.ctx, sc.user, cmd)
|
||||
require.NoError(t, err)
|
||||
dashJSON := map[string]interface{}{
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
dashJSON := map[string]any{
|
||||
"panels": []any{
|
||||
map[string]any{
|
||||
"id": int64(1),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
map[string]any{
|
||||
"collapsed": true,
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 0,
|
||||
@@ -130,26 +130,26 @@ func TestConnectLibraryPanelsForDashboard(t *testing.T) {
|
||||
},
|
||||
"id": int64(2),
|
||||
"type": "row",
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"panels": []any{
|
||||
map[string]any{
|
||||
"id": int64(3),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 0,
|
||||
"y": 7,
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
map[string]any{
|
||||
"id": int64(4),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 6,
|
||||
"y": 13,
|
||||
},
|
||||
"datasource": "${DS_GDEV-TESTDATA}",
|
||||
"libraryPanel": map[string]interface{}{
|
||||
"libraryPanel": map[string]any{
|
||||
"uid": sc.initialResult.Result.UID,
|
||||
},
|
||||
"title": "Inside row",
|
||||
@@ -157,16 +157,16 @@ func TestConnectLibraryPanelsForDashboard(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
map[string]any{
|
||||
"id": int64(5),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 0,
|
||||
"y": 19,
|
||||
},
|
||||
"datasource": "${DS_GDEV-TESTDATA}",
|
||||
"libraryPanel": map[string]interface{}{
|
||||
"libraryPanel": map[string]any{
|
||||
"uid": outsidePanel.UID,
|
||||
},
|
||||
"title": "Outside row",
|
||||
@@ -192,27 +192,27 @@ func TestConnectLibraryPanelsForDashboard(t *testing.T) {
|
||||
|
||||
scenarioWithLibraryPanel(t, "When an admin tries to store a dashboard with a library panel without uid, it should fail",
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
dashJSON := map[string]interface{}{
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
dashJSON := map[string]any{
|
||||
"panels": []any{
|
||||
map[string]any{
|
||||
"id": int64(1),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
map[string]any{
|
||||
"id": int64(2),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 6,
|
||||
"y": 0,
|
||||
},
|
||||
"datasource": "${DS_GDEV-TESTDATA}",
|
||||
"libraryPanel": map[string]interface{}{
|
||||
"libraryPanel": map[string]any{
|
||||
"name": sc.initialResult.Result.Name,
|
||||
},
|
||||
"title": "Text - Library Panel",
|
||||
@@ -247,27 +247,27 @@ func TestConnectLibraryPanelsForDashboard(t *testing.T) {
|
||||
Kind: int64(model.PanelElement),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
dashJSON := map[string]interface{}{
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
dashJSON := map[string]any{
|
||||
"panels": []any{
|
||||
map[string]any{
|
||||
"id": int64(1),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
map[string]any{
|
||||
"id": int64(4),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 6,
|
||||
"y": 0,
|
||||
},
|
||||
"datasource": "${DS_GDEV-TESTDATA}",
|
||||
"libraryPanel": map[string]interface{}{
|
||||
"libraryPanel": map[string]any{
|
||||
"uid": unused.UID,
|
||||
},
|
||||
"title": "Unused Libray Panel",
|
||||
@@ -284,26 +284,26 @@ func TestConnectLibraryPanelsForDashboard(t *testing.T) {
|
||||
err = sc.elementService.ConnectElementsToDashboard(sc.ctx, sc.user, []string{sc.initialResult.Result.UID}, dashInDB.ID)
|
||||
require.NoError(t, err)
|
||||
|
||||
panelJSON := []interface{}{
|
||||
map[string]interface{}{
|
||||
panelJSON := []any{
|
||||
map[string]any{
|
||||
"id": int64(1),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
map[string]any{
|
||||
"id": int64(2),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 6,
|
||||
"y": 0,
|
||||
},
|
||||
"datasource": "${DS_GDEV-TESTDATA}",
|
||||
"libraryPanel": map[string]interface{}{
|
||||
"libraryPanel": map[string]any{
|
||||
"uid": sc.initialResult.Result.UID,
|
||||
},
|
||||
"title": "Text - Library Panel",
|
||||
@@ -343,9 +343,9 @@ func TestImportLibraryPanelsForDashboard(t *testing.T) {
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
var missingUID = "jL6MrxCMz"
|
||||
var missingName = "Missing Library Panel"
|
||||
var missingModel = map[string]interface{}{
|
||||
var missingModel = map[string]any{
|
||||
"id": int64(2),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": int64(6),
|
||||
"w": int64(6),
|
||||
"x": int64(0),
|
||||
@@ -353,31 +353,31 @@ func TestImportLibraryPanelsForDashboard(t *testing.T) {
|
||||
},
|
||||
"description": "",
|
||||
"datasource": "${DS_GDEV-TESTDATA}",
|
||||
"libraryPanel": map[string]interface{}{
|
||||
"libraryPanel": map[string]any{
|
||||
"uid": missingUID,
|
||||
"name": missingName,
|
||||
},
|
||||
"title": "Text - Library Panel",
|
||||
"type": "text",
|
||||
}
|
||||
var libraryElements = map[string]interface{}{
|
||||
missingUID: map[string]interface{}{
|
||||
var libraryElements = map[string]any{
|
||||
missingUID: map[string]any{
|
||||
"model": missingModel,
|
||||
},
|
||||
}
|
||||
|
||||
panels := []interface{}{
|
||||
map[string]interface{}{
|
||||
panels := []any{
|
||||
map[string]any{
|
||||
"id": int64(1),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"libraryPanel": map[string]interface{}{
|
||||
map[string]any{
|
||||
"libraryPanel": map[string]any{
|
||||
"uid": missingUID,
|
||||
"name": missingName,
|
||||
},
|
||||
@@ -407,18 +407,18 @@ func TestImportLibraryPanelsForDashboard(t *testing.T) {
|
||||
var existingUID = sc.initialResult.Result.UID
|
||||
var existingName = sc.initialResult.Result.Name
|
||||
|
||||
panels := []interface{}{
|
||||
map[string]interface{}{
|
||||
panels := []any{
|
||||
map[string]any{
|
||||
"id": int64(1),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"libraryPanel": map[string]interface{}{
|
||||
map[string]any{
|
||||
"libraryPanel": map[string]any{
|
||||
"uid": sc.initialResult.Result.UID,
|
||||
"name": sc.initialResult.Result.Name,
|
||||
},
|
||||
@@ -450,16 +450,16 @@ func TestImportLibraryPanelsForDashboard(t *testing.T) {
|
||||
func(t *testing.T, sc scenarioContext) {
|
||||
var outsideUID = "jL6MrxCMz"
|
||||
var outsideName = "Outside Library Panel"
|
||||
var outsideModel = map[string]interface{}{
|
||||
var outsideModel = map[string]any{
|
||||
"id": int64(5),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 0,
|
||||
"y": 19,
|
||||
},
|
||||
"datasource": "${DS_GDEV-TESTDATA}",
|
||||
"libraryPanel": map[string]interface{}{
|
||||
"libraryPanel": map[string]any{
|
||||
"uid": outsideUID,
|
||||
"name": outsideName,
|
||||
},
|
||||
@@ -469,16 +469,16 @@ func TestImportLibraryPanelsForDashboard(t *testing.T) {
|
||||
|
||||
var insideUID = "iK7NsyDNz"
|
||||
var insideName = "Inside Library Panel"
|
||||
var insideModel = map[string]interface{}{
|
||||
var insideModel = map[string]any{
|
||||
"id": int64(4),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 6,
|
||||
"y": 13,
|
||||
},
|
||||
"datasource": "${DS_GDEV-TESTDATA}",
|
||||
"libraryPanel": map[string]interface{}{
|
||||
"libraryPanel": map[string]any{
|
||||
"uid": insideUID,
|
||||
"name": insideName,
|
||||
},
|
||||
@@ -486,34 +486,34 @@ func TestImportLibraryPanelsForDashboard(t *testing.T) {
|
||||
"type": "text",
|
||||
}
|
||||
|
||||
var libraryElements = map[string]interface{}{
|
||||
outsideUID: map[string]interface{}{
|
||||
var libraryElements = map[string]any{
|
||||
outsideUID: map[string]any{
|
||||
"model": outsideModel,
|
||||
},
|
||||
insideUID: map[string]interface{}{
|
||||
insideUID: map[string]any{
|
||||
"model": insideModel,
|
||||
},
|
||||
}
|
||||
|
||||
panels := []interface{}{
|
||||
map[string]interface{}{
|
||||
panels := []any{
|
||||
map[string]any{
|
||||
"id": int64(1),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"libraryPanel": map[string]interface{}{
|
||||
map[string]any{
|
||||
"libraryPanel": map[string]any{
|
||||
"uid": outsideUID,
|
||||
"name": outsideName,
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
map[string]any{
|
||||
"collapsed": true,
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 0,
|
||||
@@ -521,18 +521,18 @@ func TestImportLibraryPanelsForDashboard(t *testing.T) {
|
||||
},
|
||||
"id": int64(2),
|
||||
"type": "row",
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"panels": []any{
|
||||
map[string]any{
|
||||
"id": int64(3),
|
||||
"gridPos": map[string]interface{}{
|
||||
"gridPos": map[string]any{
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 0,
|
||||
"y": 7,
|
||||
},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"libraryPanel": map[string]interface{}{
|
||||
map[string]any{
|
||||
"libraryPanel": map[string]any{
|
||||
"uid": insideUID,
|
||||
"name": insideName,
|
||||
},
|
||||
@@ -574,7 +574,7 @@ type libraryPanel struct {
|
||||
Name string
|
||||
Type string
|
||||
Description string
|
||||
Model map[string]interface{}
|
||||
Model map[string]any
|
||||
Version int64
|
||||
Meta model.LibraryElementDTOMeta
|
||||
}
|
||||
@@ -666,7 +666,7 @@ func toLibraryElement(t *testing.T, res model.LibraryElementDTO) libraryElement
|
||||
}
|
||||
}
|
||||
|
||||
func getExpected(t *testing.T, res model.LibraryElementDTO, UID string, name string, lEModel map[string]interface{}) libraryElement {
|
||||
func getExpected(t *testing.T, res model.LibraryElementDTO, UID string, name string, lEModel map[string]any) libraryElement {
|
||||
marshalled, err := json.Marshal(lEModel)
|
||||
require.NoError(t, err)
|
||||
var libModel libraryElementModel
|
||||
@@ -777,7 +777,7 @@ func scenarioWithLibraryPanel(t *testing.T, desc string, fn func(t *testing.T, s
|
||||
}
|
||||
resp, err := sc.elementService.CreateElement(sc.ctx, sc.user, command)
|
||||
require.NoError(t, err)
|
||||
var model map[string]interface{}
|
||||
var model map[string]any
|
||||
err = json.Unmarshal(resp.Model, &model)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user