From c87533a26677a189b0b5f9e59b57f13ef98bdd4e Mon Sep 17 00:00:00 2001 From: Hitesh Pattanayak <48874082+HiteshRepo@users.noreply.github.com> Date: Wed, 3 Jan 2024 14:18:44 +0530 Subject: [PATCH] fix tests referencing top level of sharepointInfo for listInfo (#4936) fix tests referencing top level of SharepointInfo for list details instead of nested ListInfo. also disables a test that requires list backup to be enabled in CLI level. #### Does this PR need a docs update or release note? - [x] :no_entry: No #### Type of change - [x] :bug: Bugfix #### Issue(s) https://github.com/alcionai/corso/actions/runs/7312375792/job/19922878417#step:6:666 #### Test Plan - [x] :muscle: Manual - [x] :zap: Unit test - [x] :green_heart: E2E --- src/cli/backup/sharepoint_e2e_test.go | 36 ++++++++++++++----- .../m365/collection/site/collection_test.go | 11 ++++-- .../m365/collection/site/restore_test.go | 2 +- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/cli/backup/sharepoint_e2e_test.go b/src/cli/backup/sharepoint_e2e_test.go index 8e46ebb47..f5147bc85 100644 --- a/src/cli/backup/sharepoint_e2e_test.go +++ b/src/cli/backup/sharepoint_e2e_test.go @@ -21,6 +21,7 @@ import ( "github.com/alcionai/corso/src/internal/operations" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/internal/tester/tconfig" + "github.com/alcionai/corso/src/pkg/backup/details" "github.com/alcionai/corso/src/pkg/config" "github.com/alcionai/corso/src/pkg/path" "github.com/alcionai/corso/src/pkg/selectors" @@ -138,6 +139,8 @@ func runSharepointBackupCategoryTest(suite *BackupSharepointE2ESuite, category s } func (suite *BackupSharepointE2ESuite) TestSharepointBackupCmd_siteNotFound_lists() { + // Issue: https://github.com/alcionai/corso/issues/4754 + suite.T().Skip("un-skip test when lists support is enabled") runSharepointBackupSiteNotFoundTest(suite, flags.DataLists) } @@ -338,19 +341,34 @@ func runSharepointDetailsCmdTest(suite *PreparedBackupSharepointE2ESuite, catego result := suite.dpnd.recorder.String() i := 0 - foundList := 0 + findings := make(map[path.CategoryType]int) - for _, ent := range deets.Entries { - if ent.SharePoint != nil && ent.SharePoint.ItemName != "" { - suite.Run(fmt.Sprintf("detail %d", i), func() { - assert.Contains(suite.T(), result, ent.ShortRef) - }) - foundList++ - i++ + incrementor := func(cond bool, cat path.CategoryType) { + if cond { + findings[cat]++ } } - assert.GreaterOrEqual(t, foundList, 1) + for _, ent := range deets.Entries { + if ent.SharePoint == nil { + continue + } + + isSharePointList := ent.SharePoint.ItemType == details.SharePointList + hasListName := isSharePointList && len(ent.SharePoint.List.Name) > 0 + hasItemName := !isSharePointList && len(ent.SharePoint.ItemName) > 0 + + incrementor(hasListName, category) + incrementor(hasItemName, category) + + suite.Run(fmt.Sprintf("detail %d", i), func() { + assert.Contains(suite.T(), result, ent.ShortRef) + }) + + i++ + } + + assert.GreaterOrEqual(t, findings[category], 1) } // --------------------------------------------------------------------------- diff --git a/src/internal/m365/collection/site/collection_test.go b/src/internal/m365/collection/site/collection_test.go index 2748e1eb6..da8c6407c 100644 --- a/src/internal/m365/collection/site/collection_test.go +++ b/src/internal/m365/collection/site/collection_test.go @@ -79,8 +79,8 @@ func (suite *SharePointCollectionSuite) TestPrefetchCollection_Items() { tables := []struct { name, itemName string - cat path.CategoryType scope selectors.SharePointScope + cat path.CategoryType getter getItemByIDer getDir func(t *testing.T) path.Path getItem func(t *testing.T, itemName string) data.Item @@ -115,7 +115,9 @@ func (suite *SharePointCollectionSuite) TestPrefetchCollection_Items() { require.NoError(t, err, clues.ToCore(err)) info := &details.SharePointInfo{ - ItemName: name, + List: &details.ListInfo{ + Name: name, + }, } data, err := data.NewPrefetchedItemWithInfo( @@ -194,7 +196,10 @@ func (suite *SharePointCollectionSuite) TestPrefetchCollection_Items() { assert.NotNil(t, info) assert.NotNil(t, info.SharePoint) - assert.Equal(t, test.itemName, info.SharePoint.ItemName) + + if test.cat == path.ListsCategory { + assert.Equal(t, test.itemName, info.SharePoint.List.Name) + } }) } } diff --git a/src/internal/m365/collection/site/restore_test.go b/src/internal/m365/collection/site/restore_test.go index 6323b9858..1c9335ab2 100644 --- a/src/internal/m365/collection/site/restore_test.go +++ b/src/internal/m365/collection/site/restore_test.go @@ -168,7 +168,7 @@ func deleteList( assert.NoError(t, err, "getting site lists", clues.ToCore(err)) for _, l := range lists { - if ptr.Val(l.GetDisplayName()) == deets.SharePoint.ItemName { + if ptr.Val(l.GetDisplayName()) == deets.SharePoint.List.Name { isFound = true deleteID = ptr.Val(l.GetId())