-
Notifications
You must be signed in to change notification settings - Fork 23
/
export.go
62 lines (51 loc) · 1.26 KB
/
export.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package driveish
import (
"context"
"io/fs"
"github.com/alcionai/clues"
"github.com/microsoftgraph/msgraph-sdk-go/models"
"github.com/alcionai/corso/src/cmd/sanity_test/common"
"github.com/alcionai/corso/src/internal/common/ptr"
"github.com/alcionai/corso/src/pkg/services/m365/api"
)
func CheckExport(
ctx context.Context,
ac api.Client,
drive models.Driveable,
envs common.Envs,
) {
var (
driveID = ptr.Val(drive.GetId())
driveName = ptr.Val(drive.GetName())
)
ctx = clues.Add(
ctx,
"drive_id", driveID,
"drive_name", driveName)
root := populateSanitree(
ctx,
ac,
driveID,
[]string{envs.SourceContainer})
sourceTree, ok := root.Children[envs.SourceContainer]
common.Assert(
ctx,
func() bool { return ok },
"should find root-level source data folder",
envs.SourceContainer,
"not found")
fpTree := common.BuildFilepathSanitree(ctx, envs.RestoreContainer)
comparator := func(
ctx context.Context,
expect *common.Sanitree[models.DriveItemable, models.DriveItemable],
result *common.Sanitree[fs.FileInfo, fs.FileInfo],
) {
common.CompareLeaves(ctx, expect.Leaves, result.Leaves, nil)
}
common.CompareDiffTrees(
ctx,
sourceTree,
fpTree.Children[envs.SourceContainer],
comparator)
common.Infof(ctx, "Success")
}