CloudMigrations: cover cases where library panel has no folder (#94405)

This commit is contained in:
Matheus Macabu 2024-10-08 15:14:23 +02:00 committed by GitHub
parent ee65f89533
commit 96384b5181
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -672,6 +672,7 @@ func TestGetParentNames(t *testing.T) {
},
libraryElements: []libraryElement{
{UID: "libraryElementUID-0", FolderUID: &libraryElementFolderUID},
{UID: "libraryElementUID-1"},
},
expectedDashParentNames: []string{"", "Folder A", "Folder B"},
expectedFoldParentNames: []string{"Folder A"},

View File

@ -588,7 +588,9 @@ func (s *Service) getParentNames(ctx context.Context, signedInUser *user.SignedI
parentFolderUIDsSet[f.ParentUID] = struct{}{}
}
for _, libraryElement := range libraryElements {
parentFolderUIDsSet[*libraryElement.FolderUID] = struct{}{}
if libraryElement.FolderUID != nil {
parentFolderUIDsSet[*libraryElement.FolderUID] = struct{}{}
}
}
parentFolderUIDsSlice := make([]string, 0, len(parentFolderUIDsSet))
for parentFolderUID := range parentFolderUIDsSet {
@ -610,7 +612,9 @@ func (s *Service) getParentNames(ctx context.Context, signedInUser *user.SignedI
parentNamesByType[cloudmigration.FolderDataType][f.UID] = foldersUIDsToFolderName[f.ParentUID]
}
for _, libraryElement := range libraryElements {
parentNamesByType[cloudmigration.LibraryElementDataType][libraryElement.UID] = foldersUIDsToFolderName[*libraryElement.FolderUID]
if libraryElement.FolderUID != nil {
parentNamesByType[cloudmigration.LibraryElementDataType][libraryElement.UID] = foldersUIDsToFolderName[*libraryElement.FolderUID]
}
}
return parentNamesByType, err