mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 19:52:38 +08:00
CloudMigrations: Improvements to backend (#91012)
* E2C: Add stat rollup to MigrationSummary * fix report event url * open form in new page * sort folders by heirarchy * undo accidental commit * remove another commit * make folder sorting dynamic --------- Co-authored-by: joshhunt <josh@trtr.co>
This commit is contained in:
@ -384,6 +384,29 @@ func Test_DeletedDashboardsNotMigrated(t *testing.T) {
|
||||
assert.Equal(t, 1, dashCount)
|
||||
}
|
||||
|
||||
// Implementation inspired by ChatGPT, OpenAI's language model.
|
||||
func Test_SortFolders(t *testing.T) {
|
||||
folders := []folder.CreateFolderCommand{
|
||||
{UID: "a", ParentUID: "", Title: "Root"},
|
||||
{UID: "b", ParentUID: "a", Title: "Child of Root"},
|
||||
{UID: "c", ParentUID: "b", Title: "Child of b"},
|
||||
{UID: "d", ParentUID: "a", Title: "Another Child of Root"},
|
||||
{UID: "e", ParentUID: "", Title: "Another Root"},
|
||||
}
|
||||
|
||||
expected := []folder.CreateFolderCommand{
|
||||
{UID: "a", ParentUID: "", Title: "Root"},
|
||||
{UID: "e", ParentUID: "", Title: "Another Root"},
|
||||
{UID: "b", ParentUID: "a", Title: "Child of Root"},
|
||||
{UID: "d", ParentUID: "a", Title: "Another Child of Root"},
|
||||
{UID: "c", ParentUID: "b", Title: "Child of b"},
|
||||
}
|
||||
|
||||
sortedFolders := sortFolders(folders)
|
||||
|
||||
require.Equal(t, expected, sortedFolders)
|
||||
}
|
||||
|
||||
func ctxWithSignedInUser() context.Context {
|
||||
c := &contextmodel.ReqContext{
|
||||
SignedInUser: &user.SignedInUser{OrgID: 1},
|
||||
|
Reference in New Issue
Block a user