diff --git a/.github/workflows/sanity-test.yaml b/.github/workflows/sanity-test.yaml index 490070146..9f7bbd61e 100644 --- a/.github/workflows/sanity-test.yaml +++ b/.github/workflows/sanity-test.yaml @@ -391,7 +391,7 @@ jobs: log-dir: ${{ env.CORSO_LOG_DIR }} with-export: true - # generate some more enteries for incremental check + # generate some more entries for incremental check - name: Groups - Create new data (for incremental) timeout-minutes: 30 working-directory: ./src/cmd/factory diff --git a/src/cmd/sanity_test/export/groups.go b/src/cmd/sanity_test/export/groups.go index 1d288c32a..f88bc353f 100644 --- a/src/cmd/sanity_test/export/groups.go +++ b/src/cmd/sanity_test/export/groups.go @@ -3,6 +3,8 @@ package export import ( "context" "io/fs" + "path/filepath" + "strings" "github.com/microsoftgraph/msgraph-sdk-go/models" @@ -21,21 +23,31 @@ func CheckGroupsExport( // assumes we only need to sanity check the default site. // should we expand this to check all sites in the group? // are we backing up / restoring more than the default site? + site, err := ac.Sites().GetByID(ctx, envs.TeamSiteID, api.CallConfig{}) + if err != nil { + common.Fatal(ctx, "getting the drive:", err) + } + drive, err := ac.Sites().GetDefaultDrive(ctx, envs.TeamSiteID) if err != nil { common.Fatal(ctx, "getting the drive:", err) } + checkChannelMessagesExport( + ctx, + ac, + envs) + + envs.RestoreContainer = filepath.Join( + envs.RestoreContainer, + "Libraries", + ptr.Val(site.GetName()), + "Documents") // check in default loc driveish.CheckExport( ctx, ac, drive, envs) - - checkChannelMessagesExport( - ctx, - ac, - envs) } func checkChannelMessagesExport( @@ -55,7 +67,19 @@ func checkChannelMessagesExport( expect *common.Sanitree[models.Channelable, models.ChatMessageable], result *common.Sanitree[fs.FileInfo, fs.FileInfo], ) { - common.CompareLeaves(ctx, expect.Leaves, result.Leaves, nil) + for key := range expect.Leaves { + expect.Leaves[key].Size = 0 // msg sizes cannot be compared + } + + updatedResultLeaves := map[string]*common.Sanileaf[fs.FileInfo, fs.FileInfo]{} + + for key, leaf := range result.Leaves { + key = strings.TrimSuffix(key, ".json") + leaf.Size = 0 // we cannot compare sizes + updatedResultLeaves[key] = leaf + } + + common.CompareLeaves(ctx, expect.Leaves, updatedResultLeaves, nil) } common.CompareDiffTrees( @@ -107,7 +131,21 @@ func populateMessagesSanitree( common.Fatal(ctx, "getting channel messages", err) } + filteredMsgs := []models.ChatMessageable{} + for _, msg := range msgs { + // filter out system messages (we don't really work with them) + if api.IsNotSystemMessage(msg) { + filteredMsgs = append(filteredMsgs, msg) + } + } + + if len(filteredMsgs) == 0 { + common.Infof(ctx, "skipped empty channel: %s", ptr.Val(ch.GetDisplayName())) + continue + } + + for _, msg := range filteredMsgs { child.Leaves[ptr.Val(msg.GetId())] = &common.Sanileaf[ models.Channelable, models.ChatMessageable, diff --git a/src/cmd/sanity_test/export/sharepoint.go b/src/cmd/sanity_test/export/sharepoint.go index eca3c1e4c..eceea6ca5 100644 --- a/src/cmd/sanity_test/export/sharepoint.go +++ b/src/cmd/sanity_test/export/sharepoint.go @@ -2,6 +2,7 @@ package export import ( "context" + "path/filepath" "github.com/alcionai/corso/src/cmd/sanity_test/common" "github.com/alcionai/corso/src/cmd/sanity_test/driveish" @@ -18,6 +19,7 @@ func CheckSharePointExport( common.Fatal(ctx, "getting the drive:", err) } + envs.RestoreContainer = filepath.Join(envs.RestoreContainer, "Libraries/Documents") // check in default loc driveish.CheckExport( ctx, ac, diff --git a/src/pkg/services/m365/api/channels_pager.go b/src/pkg/services/m365/api/channels_pager.go index a822ac4da..375ed6d81 100644 --- a/src/pkg/services/m365/api/channels_pager.go +++ b/src/pkg/services/m365/api/channels_pager.go @@ -165,7 +165,7 @@ func (c Channels) NewChannelMessageDeltaPager( // unknownFutureValue. const channelMessageSystemMessageContent = "" -func filterOutSystemMessages(cm models.ChatMessageable) bool { +func IsNotSystemMessage(cm models.ChatMessageable) bool { if ptr.Val(cm.GetMessageType()) == models.SYSTEMEVENTMESSAGE_CHATMESSAGETYPE { return false } @@ -195,7 +195,7 @@ func (c Channels) GetChannelMessageIDs( cc.CanMakeDeltaQueries, 0, pagers.AddedAndRemovedByDeletedDateTime[models.ChatMessageable], - filterOutSystemMessages) + IsNotSystemMessage) return aar, clues.Stack(err).OrNil() } diff --git a/src/pkg/services/m365/api/channels_pager_test.go b/src/pkg/services/m365/api/channels_pager_test.go index a46dc2c63..2b6635953 100644 --- a/src/pkg/services/m365/api/channels_pager_test.go +++ b/src/pkg/services/m365/api/channels_pager_test.go @@ -152,7 +152,7 @@ func testEnumerateChannelMessageReplies( assert.Equal(t, replyIDs, msgReplyIDs) } -func (suite *ChannelsPagerIntgSuite) TestFilterOutSystemMessages() { +func (suite *ChannelsPagerIntgSuite) TestIsSystemMessage() { systemMessage := models.NewChatMessage() systemMessage.SetMessageType(ptr.To(models.SYSTEMEVENTMESSAGE_CHATMESSAGETYPE)) @@ -211,7 +211,7 @@ func (suite *ChannelsPagerIntgSuite) TestFilterOutSystemMessages() { } for _, test := range table { suite.Run(test.name, func() { - test.expect(suite.T(), filterOutSystemMessages(test.cm)) + test.expect(suite.T(), IsNotSystemMessage(test.cm)) }) } }