Fix sanity tests for exchange emails export (#4756)
<!-- PR description--> --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [x] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #<issue> #### Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
496fcf3a9b
commit
3314acc78e
@ -149,7 +149,7 @@ type NodeComparator[ET, EL, RT, RL any] func(
|
||||
// different data types. The two trees are expected to represent
|
||||
// a common hierarchy.
|
||||
//
|
||||
// Additional comparisons besides the tre hierarchy are optionally
|
||||
// Additional comparisons besides the tree hierarchy are optionally
|
||||
// left to the caller by population of the NodeComparator func.
|
||||
func CompareDiffTrees[ET, EL, RT, RL any](
|
||||
ctx context.Context,
|
||||
|
||||
@ -36,12 +36,10 @@ func CheckEmailExport(
|
||||
expect *common.Sanitree[models.MailFolderable, any],
|
||||
result *common.Sanitree[fs.FileInfo, fs.FileInfo],
|
||||
) {
|
||||
modifiedExpectedLeaves := map[string]*common.Sanileaf[models.MailFolderable, any]{}
|
||||
modifiedResultLeaves := map[string]*common.Sanileaf[fs.FileInfo, fs.FileInfo]{}
|
||||
|
||||
for key, val := range expect.Leaves {
|
||||
for _, val := range expect.Leaves {
|
||||
val.Size = 0 // we cannot match up sizes
|
||||
modifiedExpectedLeaves[key] = val
|
||||
}
|
||||
|
||||
for key, val := range result.Leaves {
|
||||
|
||||
@ -29,11 +29,12 @@ func CheckEmailRestoration(
|
||||
"source_container_id", sourceTree.ID,
|
||||
"source_container_name", sourceTree.Name)
|
||||
|
||||
common.AssertEqualTrees[models.MailFolderable, any](
|
||||
// NOTE: We cannot compare leaves as the IDs of the restored items
|
||||
// differ from the original ones.
|
||||
common.CompareDiffTrees[models.MailFolderable, any](
|
||||
ctx,
|
||||
sourceTree,
|
||||
restoredTree.Children[envs.SourceContainer],
|
||||
nil,
|
||||
nil)
|
||||
|
||||
common.Infof(ctx, "Success")
|
||||
@ -122,7 +123,7 @@ func recursivelyBuildTree(
|
||||
}
|
||||
|
||||
for _, child := range childFolders {
|
||||
if int(ptr.Val(child.GetTotalItemCount())) == 0 {
|
||||
if int(ptr.Val(child.GetTotalItemCount()))+len(childFolders) == 0 {
|
||||
common.Infof(ctx, "skipped empty folder: %s/%s", location, ptr.Val(child.GetDisplayName()))
|
||||
continue
|
||||
}
|
||||
@ -133,9 +134,27 @@ func recursivelyBuildTree(
|
||||
ID: ptr.Val(child.GetId()),
|
||||
Name: ptr.Val(child.GetDisplayName()),
|
||||
CountLeaves: int(ptr.Val(child.GetTotalItemCount())),
|
||||
Leaves: map[string]*common.Sanileaf[models.MailFolderable, any]{},
|
||||
Children: map[string]*common.Sanitree[models.MailFolderable, any]{},
|
||||
}
|
||||
|
||||
mails, err := ac.Mail().GetItemsInContainer(ctx, userID, c.ID)
|
||||
if err != nil {
|
||||
common.Fatal(ctx, "getting child containers", err)
|
||||
}
|
||||
|
||||
for _, mail := range mails {
|
||||
m := &common.Sanileaf[models.MailFolderable, any]{
|
||||
Parent: c,
|
||||
Self: mail,
|
||||
ID: ptr.Val(mail.GetId()),
|
||||
Name: ptr.Val(mail.GetSubject()),
|
||||
Size: int64(len(ptr.Val(mail.GetBody().GetContent()))),
|
||||
}
|
||||
|
||||
c.Leaves[m.ID] = m
|
||||
}
|
||||
|
||||
stree.Children[c.Name] = c
|
||||
|
||||
recursivelyBuildTree(ctx, ac, c, userID, location+c.Name+"/")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user