mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 23:55:47 -06:00
Fix capitalising Folder structs (#79207)
* Fix capitalising Folder structs * Add swagger and fix api dashboard test * Add swagger files with bingo installed
This commit is contained in:
parent
9e71dc801d
commit
550746be71
@ -7,11 +7,11 @@ import (
|
||||
)
|
||||
|
||||
type Folder struct {
|
||||
// Deprecated: use Uid instead
|
||||
Id int64 `json:"id"`
|
||||
Uid string `json:"uid"`
|
||||
// Deprecated: use UID instead
|
||||
ID int64 `json:"id" xorm:"pk autoincr 'id'"`
|
||||
UID string `json:"uid" xorm:"uid"`
|
||||
Title string `json:"title"`
|
||||
Url string `json:"url"`
|
||||
URL string `json:"url" xoem:"url"`
|
||||
HasACL bool `json:"hasAcl" xorm:"has_acl"`
|
||||
CanSave bool `json:"canSave"`
|
||||
CanEdit bool `json:"canEdit"`
|
||||
@ -30,8 +30,8 @@ type Folder struct {
|
||||
}
|
||||
|
||||
type FolderSearchHit struct {
|
||||
Id int64 `json:"id"`
|
||||
Uid string `json:"uid"`
|
||||
ID int64 `json:"id" xorm:"pk autoincr 'id'"`
|
||||
UID string `json:"uid" xorm:"uid"`
|
||||
Title string `json:"title"`
|
||||
ParentUID string `json:"parentUid,omitempty"`
|
||||
}
|
||||
|
@ -63,8 +63,8 @@ func (hs *HTTPServer) GetFolders(c *contextmodel.ReqContext) response.Response {
|
||||
result := make([]dtos.FolderSearchHit, 0)
|
||||
for _, f := range folders {
|
||||
result = append(result, dtos.FolderSearchHit{
|
||||
Id: f.ID, // nolint:staticcheck
|
||||
Uid: f.UID,
|
||||
ID: f.ID, // nolint:staticcheck
|
||||
UID: f.UID,
|
||||
Title: f.Title,
|
||||
ParentUID: f.ParentUID,
|
||||
})
|
||||
@ -360,17 +360,17 @@ func (hs *HTTPServer) newToFolderDto(c *contextmodel.ReqContext, f *folder.Folde
|
||||
canView, _ := g.CanView()
|
||||
if !canView {
|
||||
return dtos.Folder{
|
||||
Uid: REDACTED,
|
||||
UID: REDACTED,
|
||||
Title: REDACTED,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
return dtos.Folder{
|
||||
Id: f.ID, // nolint:staticcheck
|
||||
Uid: f.UID,
|
||||
ID: f.ID, // nolint:staticcheck
|
||||
UID: f.UID,
|
||||
Title: f.Title,
|
||||
Url: f.URL,
|
||||
URL: f.URL,
|
||||
HasACL: f.HasACL,
|
||||
CanSave: canSave,
|
||||
CanEdit: canEdit,
|
||||
|
@ -146,8 +146,8 @@ func TestFoldersCreateAPIEndpoint(t *testing.T) {
|
||||
|
||||
if tc.expectedCode == http.StatusOK {
|
||||
// nolint:staticcheck
|
||||
assert.Equal(t, int64(1), folder.Id)
|
||||
assert.Equal(t, "uid", folder.Uid)
|
||||
assert.Equal(t, int64(1), folder.ID)
|
||||
assert.Equal(t, "uid", folder.UID)
|
||||
assert.Equal(t, "Folder", folder.Title)
|
||||
}
|
||||
})
|
||||
@ -251,8 +251,8 @@ func TestFoldersUpdateAPIEndpoint(t *testing.T) {
|
||||
|
||||
if tc.expectedCode == http.StatusOK {
|
||||
// nolint:staticcheck
|
||||
assert.Equal(t, int64(1), folder.Id)
|
||||
assert.Equal(t, "uid", folder.Uid)
|
||||
assert.Equal(t, int64(1), folder.ID)
|
||||
assert.Equal(t, "uid", folder.UID)
|
||||
assert.Equal(t, "Folder upd", folder.Title)
|
||||
}
|
||||
})
|
||||
@ -515,7 +515,7 @@ func TestFolderGetAPIEndpoint(t *testing.T) {
|
||||
require.Equal(t, len(folder.Parents), len(tc.expectedParentTitles))
|
||||
|
||||
for i := 0; i < len(tc.expectedParentUIDs); i++ {
|
||||
assert.Equal(t, tc.expectedParentUIDs[i], folder.Parents[i].Uid)
|
||||
assert.Equal(t, tc.expectedParentUIDs[i], folder.Parents[i].UID)
|
||||
assert.Equal(t, tc.expectedParentTitles[i], folder.Parents[i].Title)
|
||||
}
|
||||
require.NoError(t, resp.Body.Close())
|
||||
|
@ -328,7 +328,7 @@ func TestIntegrationCreate(t *testing.T) {
|
||||
buf1 := &bytes.Buffer{}
|
||||
err = json.NewEncoder(buf1).Encode(dashboards.SaveDashboardCommand{
|
||||
Dashboard: dashboardDataOne,
|
||||
FolderUID: folder.Uid,
|
||||
FolderUID: folder.UID,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
u := fmt.Sprintf("http://admin:admin@%s/api/dashboards/db", grafanaListedAddr)
|
||||
@ -347,7 +347,7 @@ func TestIntegrationCreate(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, m["id"])
|
||||
assert.NotEmpty(t, m["uid"])
|
||||
assert.Equal(t, folder.Uid, m["folderUid"])
|
||||
assert.Equal(t, folder.UID, m["folderUid"])
|
||||
})
|
||||
|
||||
t.Run("create dashboard under folder (using deprecated folder sequential ID) should succeed", func(t *testing.T) {
|
||||
@ -358,7 +358,7 @@ func TestIntegrationCreate(t *testing.T) {
|
||||
buf1 := &bytes.Buffer{}
|
||||
err = json.NewEncoder(buf1).Encode(dashboards.SaveDashboardCommand{
|
||||
Dashboard: dashboardDataOne,
|
||||
FolderID: folder.Id, // nolint:staticcheck
|
||||
FolderID: folder.ID, // nolint:staticcheck
|
||||
})
|
||||
require.NoError(t, err)
|
||||
u := fmt.Sprintf("http://admin:admin@%s/api/dashboards/db", grafanaListedAddr)
|
||||
@ -377,7 +377,7 @@ func TestIntegrationCreate(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, m["id"])
|
||||
assert.NotEmpty(t, m["uid"])
|
||||
assert.Equal(t, folder.Uid, m["folderUid"])
|
||||
assert.Equal(t, folder.UID, m["folderUid"])
|
||||
})
|
||||
|
||||
t.Run("create dashboard under unknow folder should fail", func(t *testing.T) {
|
||||
|
@ -14139,7 +14139,7 @@
|
||||
"type": "boolean"
|
||||
},
|
||||
"id": {
|
||||
"description": "Deprecated: use Uid instead",
|
||||
"description": "Deprecated: use UID instead",
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
|
@ -5156,7 +5156,7 @@
|
||||
"type": "boolean"
|
||||
},
|
||||
"id": {
|
||||
"description": "Deprecated: use Uid instead",
|
||||
"description": "Deprecated: use UID instead",
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user