diff --git a/internal/service/folders.go b/internal/service/folders.go index bb78c6d7..b8421cf3 100644 --- a/internal/service/folders.go +++ b/internal/service/folders.go @@ -82,7 +82,11 @@ func (s *DashNGoImpl) DownloadFolderPermissions(filter filters.Filter) []string slog.Error("Unable to marshall file", "err", err, "folderName", folder.Title) continue } - dsPath := buildResourcePath(slug.Make(folder.UID), config.FolderPermissionResource) + fileName := folder.NestedPath + if fileName == "" { + fileName = folder.Title + } + dsPath := buildResourcePath(slug.Make(fileName), config.FolderPermissionResource) if err = s.storage.WriteFile(dsPath, dsPacked); err != nil { slog.Error("Unable to write file", "err", err.Error(), "filename", slug.Make(folder.Title)) } else { diff --git a/test/common_test.go b/test/common_test.go index a83066d8..b3189ebb 100644 --- a/test/common_test.go +++ b/test/common_test.go @@ -28,8 +28,7 @@ func TestMain(m *testing.M) { testModes := []string{"basicAuth", "token"} if os.Getenv("DEVELOPER") == "1" { slog.Debug("Limiting to single testMode and grafana version", slog.Any("grafanaVersion", grafanaTestVersions[1]), slog.String("testMode", testModes[0])) - // grafanaTestVersions = grafanaTestVersions[1:] - grafanaTestVersions = grafanaTestVersions[0:1] + grafanaTestVersions = grafanaTestVersions[1:] // testModes = testModes[0:1] } diff --git a/test/data/org_main-org/folders-permissions/cwsuyt_nk.json b/test/data/org_main-org/folders-permissions/cwsuyt_nk.json deleted file mode 100644 index 1c9257af..00000000 --- a/test/data/org_main-org/folders-permissions/cwsuyt_nk.json +++ /dev/null @@ -1,41 +0,0 @@ -[ - { - "created": "2024-09-10T17:44:31.000Z", - "folderId": 2, - "isFolder": true, - "permission": 4, - "permissionName": "Admin", - "title": "Other", - "uid": "CWSuYt_nk", - "updated": "2024-09-10T17:44:31.000Z", - "url": "/dashboards/f/CWSuYt_nk/other", - "userAvatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56", - "userEmail": "admin@localhost", - "userId": 1, - "userLogin": "admin" - }, - { - "created": "2024-09-10T17:44:31.000Z", - "folderId": 2, - "isFolder": true, - "permission": 2, - "permissionName": "Edit", - "role": "Editor", - "title": "Other", - "uid": "CWSuYt_nk", - "updated": "2024-09-10T17:44:31.000Z", - "url": "/dashboards/f/CWSuYt_nk/other" - }, - { - "created": "2024-09-10T17:44:31.000Z", - "folderId": 2, - "isFolder": true, - "permission": 1, - "permissionName": "View", - "role": "Viewer", - "title": "Other", - "uid": "CWSuYt_nk", - "updated": "2024-09-10T17:44:31.000Z", - "url": "/dashboards/f/CWSuYt_nk/other" - } -] \ No newline at end of file diff --git a/test/data/org_main-org/folders-permissions/n54xasa4k.json b/test/data/org_main-org/folders-permissions/n54xasa4k.json deleted file mode 100644 index a6874942..00000000 --- a/test/data/org_main-org/folders-permissions/n54xasa4k.json +++ /dev/null @@ -1,41 +0,0 @@ -[ - { - "created": "2024-09-10T17:44:31.000Z", - "folderId": 1, - "isFolder": true, - "permission": 4, - "permissionName": "Admin", - "title": "Ignored", - "uid": "N54xASa4k", - "updated": "2024-09-10T17:44:31.000Z", - "url": "/dashboards/f/N54xASa4k/ignored", - "userAvatarUrl": "/avatar/46d229b033af06a191ff2267bca9ae56", - "userEmail": "admin@localhost", - "userId": 1, - "userLogin": "admin" - }, - { - "created": "2024-09-10T17:44:31.000Z", - "folderId": 1, - "isFolder": true, - "permission": 2, - "permissionName": "Edit", - "role": "Editor", - "title": "Ignored", - "uid": "N54xASa4k", - "updated": "2024-09-10T17:44:31.000Z", - "url": "/dashboards/f/N54xASa4k/ignored" - }, - { - "created": "2024-09-10T17:44:31.000Z", - "folderId": 1, - "isFolder": true, - "permission": 1, - "permissionName": "View", - "role": "Viewer", - "title": "Ignored", - "uid": "N54xASa4k", - "updated": "2024-09-10T17:44:31.000Z", - "url": "/dashboards/f/N54xASa4k/ignored" - } -] \ No newline at end of file diff --git a/test/folder_integration_test.go b/test/folder_integration_test.go index cf32d129..9f22d5b6 100644 --- a/test/folder_integration_test.go +++ b/test/folder_integration_test.go @@ -9,6 +9,8 @@ import ( "strings" "testing" + "github.com/gosimple/slug" + "github.com/testcontainers/testcontainers-go" "github.com/esnet/gdg/internal/types" @@ -70,7 +72,7 @@ func TestFolderPermissions(t *testing.T) { data := apiClient.DownloadFolderPermissions(nil) assert.Equal(t, len(data), 2) permissionKeys := lo.Map(slices.Collect(maps.Keys(result)), func(item *types.FolderDetails, index int) string { - return fmt.Sprintf("test/data/org_main-org/folders-permissions/%s.json", strings.ToLower(item.UID)) + return fmt.Sprintf("test/data/org_main-org/folders-permissions/%s.json", slug.Make(item.NestedPath)) }) for _, item := range data { assert.True(t, slices.Contains(permissionKeys, item)) @@ -116,7 +118,7 @@ func TestFolderNestedPermissions(t *testing.T) { data := apiClient.DownloadFolderPermissions(nil) assert.Equal(t, len(data), 4) permissionKeys := lo.Map(slices.Collect(maps.Keys(result)), func(item *types.FolderDetails, index int) string { - return fmt.Sprintf("test/data/org_testing/folders-permissions/%s.json", strings.ToLower(item.UID)) + return fmt.Sprintf("test/data/org_testing/folders-permissions/%s.json", slug.Make(item.NestedPath)) }) for _, item := range data { assert.True(t, slices.Contains(permissionKeys, item))