mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 04:19:26 +08:00
Nested folders: Allow creating folders with duplicate names in different locations (#77076)
* Add API test * Add move tests * Fix create folder * Fix move * Fix test * Drop and re-create index so that allows a folder to contain a dashboard and a subfolder with same name * Get folder by title defaults to root folder and optionally fetches folder by provided parent folder * Apply suggestions from code review
This commit is contained in:

committed by
GitHub

parent
030a68bbf7
commit
478d7d58fa
@ -384,6 +384,13 @@ func TestIntegrationGet(t *testing.T) {
|
||||
UID: uid1,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
subfolderWithSameName, err := folderStore.Create(context.Background(), folder.CreateFolderCommand{
|
||||
Title: folderTitle,
|
||||
Description: folderDsc,
|
||||
OrgID: orgID,
|
||||
UID: util.GenerateShortUID(),
|
||||
ParentUID: f.UID,
|
||||
})
|
||||
|
||||
t.Cleanup(func() {
|
||||
err := folderStore.Delete(context.Background(), f.UID, orgID)
|
||||
@ -427,6 +434,23 @@ func TestIntegrationGet(t *testing.T) {
|
||||
assert.NotEmpty(t, ff.URL)
|
||||
})
|
||||
|
||||
t.Run("get folder by title and parent UID should succeed", func(t *testing.T) {
|
||||
ff, err := folderStore.Get(context.Background(), folder.GetFolderQuery{
|
||||
Title: &f.Title,
|
||||
OrgID: orgID,
|
||||
ParentUID: &uid1,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, subfolderWithSameName.UID, ff.UID)
|
||||
assert.Equal(t, subfolderWithSameName.OrgID, ff.OrgID)
|
||||
assert.Equal(t, subfolderWithSameName.Title, ff.Title)
|
||||
assert.Equal(t, subfolderWithSameName.Description, ff.Description)
|
||||
assert.Equal(t, subfolderWithSameName.ParentUID, ff.ParentUID)
|
||||
assert.NotEmpty(t, ff.Created)
|
||||
assert.NotEmpty(t, ff.Updated)
|
||||
assert.NotEmpty(t, ff.URL)
|
||||
})
|
||||
|
||||
t.Run("get folder by title should succeed", func(t *testing.T) {
|
||||
ff, err := folderStore.Get(context.Background(), folder.GetFolderQuery{
|
||||
UID: &f.UID,
|
||||
|
Reference in New Issue
Block a user