Skip to content

Commit

Permalink
Folder Permissions tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
safaci2000 committed Sep 11, 2024
1 parent bf9e29c commit c7560e6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 87 deletions.
6 changes: 5 additions & 1 deletion internal/service/folders.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions test/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}

Expand Down
41 changes: 0 additions & 41 deletions test/data/org_main-org/folders-permissions/cwsuyt_nk.json

This file was deleted.

41 changes: 0 additions & 41 deletions test/data/org_main-org/folders-permissions/n54xasa4k.json

This file was deleted.

6 changes: 4 additions & 2 deletions test/folder_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"strings"
"testing"

"github.com/gosimple/slug"

"github.com/testcontainers/testcontainers-go"

"github.com/esnet/gdg/internal/types"
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit c7560e6

Please sign in to comment.