From cddb5b2d154af113d0dee4cd828df86650d08bff Mon Sep 17 00:00:00 2001 From: Abhishek Pandey Date: Sun, 3 Dec 2023 17:39:56 -0800 Subject: [PATCH] Fix unit test failures --- .../m365/collection/drive/collections.go | 4 +-- src/pkg/services/m365/api/graph/errors.go | 26 +++++++++---------- src/pkg/services/m365/custom/drive_item.go | 2 +- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/internal/m365/collection/drive/collections.go b/src/internal/m365/collection/drive/collections.go index 704f9593b..2d6236a9a 100644 --- a/src/internal/m365/collection/drive/collections.go +++ b/src/internal/m365/collection/drive/collections.go @@ -956,8 +956,8 @@ func (c *Collections) processItem( "item_is_folder", isFolder) if item.GetMalware() != nil { - // TODO(pandeyabs): Fix this after we move conversion logic to the top of this - // func. + // TODO(pandeyabs): Fix this after we move the ToLiteDriveItemable call + // to the beginning of this func. addtl := graph.ItemInfo(custom.ToLiteDriveItemable(item)) skip := fault.FileSkip(fault.SkipMalware, driveID, itemID, itemName, addtl) diff --git a/src/pkg/services/m365/api/graph/errors.go b/src/pkg/services/m365/api/graph/errors.go index 0983e4a79..8a7bd6e29 100644 --- a/src/pkg/services/m365/api/graph/errors.go +++ b/src/pkg/services/m365/api/graph/errors.go @@ -513,17 +513,15 @@ func appendIf(a []any, k string, v *string) []any { func ItemInfo(item custom.LiteDriveItemable) map[string]any { m := map[string]any{} - // TODO(pandeyabs): These fields are not available in the LiteDriveItemable - // yet. We need to add them. - // creator := item.GetCreatedByUser() - // if creator != nil { - // m[fault.AddtlCreatedBy] = ptr.Val(creator.GetId()) - // } + creator := item.GetCreatedByUser() + if creator != nil { + m[fault.AddtlCreatedBy] = ptr.Val(creator.GetId()) + } - // lastmodder := item.GetLastModifiedByUser() - // if lastmodder != nil { - // m[fault.AddtlLastModBy] = ptr.Val(lastmodder.GetId()) - // } + lastmodder := item.GetLastModifiedByUser() + if lastmodder != nil { + m[fault.AddtlLastModBy] = ptr.Val(lastmodder.GetId()) + } parent := item.GetParentReference() if parent != nil { @@ -540,10 +538,10 @@ func ItemInfo(item custom.LiteDriveItemable) map[string]any { m[fault.AddtlContainerPath] = containerPath } - // malware := item.GetMalware() - // if malware != nil { - // m[fault.AddtlMalwareDesc] = ptr.Val(malware.GetDescription()) - // } + malware := item.GetMalware() + if malware != nil { + m[fault.AddtlMalwareDesc] = ptr.Val(malware.GetDescription()) + } return m } diff --git a/src/pkg/services/m365/custom/drive_item.go b/src/pkg/services/m365/custom/drive_item.go index ed6275d3a..152bba130 100644 --- a/src/pkg/services/m365/custom/drive_item.go +++ b/src/pkg/services/m365/custom/drive_item.go @@ -338,7 +338,7 @@ func ToLiteDriveItemable(item models.DriveItemable) LiteDriveItemable { return di } -func SetParentName(orig parentReferenceable, driveName string) parentReferenceable { +func SetParentName(orig itemReferenceable, driveName string) itemReferenceable { if orig == nil { return nil }