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

#### Type of change

<!--- Please check the type of change your PR introduces: --->
- [x] 🐛 Bugfix

#### Issue(s)
https://github.com/alcionai/corso/actions/runs/7312375792/job/19922878417#step:6:666

#### Test Plan

<!-- How will this be tested prior to merging.-->
- [x] 💪 Manual
- [x]  Unit test
- [x] 💚 E2E
This commit is contained in:
Hitesh Pattanayak 2024-01-03 14:18:44 +05:30 committed by GitHub
parent 7a8c96964c
commit c87533a266
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 13 deletions

View File

@ -21,6 +21,7 @@ import (
"github.com/alcionai/corso/src/internal/operations" "github.com/alcionai/corso/src/internal/operations"
"github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/internal/tester"
"github.com/alcionai/corso/src/internal/tester/tconfig" "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/config"
"github.com/alcionai/corso/src/pkg/path" "github.com/alcionai/corso/src/pkg/path"
"github.com/alcionai/corso/src/pkg/selectors" "github.com/alcionai/corso/src/pkg/selectors"
@ -138,6 +139,8 @@ func runSharepointBackupCategoryTest(suite *BackupSharepointE2ESuite, category s
} }
func (suite *BackupSharepointE2ESuite) TestSharepointBackupCmd_siteNotFound_lists() { 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) runSharepointBackupSiteNotFoundTest(suite, flags.DataLists)
} }
@ -338,19 +341,34 @@ func runSharepointDetailsCmdTest(suite *PreparedBackupSharepointE2ESuite, catego
result := suite.dpnd.recorder.String() result := suite.dpnd.recorder.String()
i := 0 i := 0
foundList := 0 findings := make(map[path.CategoryType]int)
incrementor := func(cond bool, cat path.CategoryType) {
if cond {
findings[cat]++
}
}
for _, ent := range deets.Entries { for _, ent := range deets.Entries {
if ent.SharePoint != nil && ent.SharePoint.ItemName != "" { 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() { suite.Run(fmt.Sprintf("detail %d", i), func() {
assert.Contains(suite.T(), result, ent.ShortRef) assert.Contains(suite.T(), result, ent.ShortRef)
}) })
foundList++
i++ i++
} }
}
assert.GreaterOrEqual(t, foundList, 1) assert.GreaterOrEqual(t, findings[category], 1)
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@ -79,8 +79,8 @@ func (suite *SharePointCollectionSuite) TestPrefetchCollection_Items() {
tables := []struct { tables := []struct {
name, itemName string name, itemName string
cat path.CategoryType
scope selectors.SharePointScope scope selectors.SharePointScope
cat path.CategoryType
getter getItemByIDer getter getItemByIDer
getDir func(t *testing.T) path.Path getDir func(t *testing.T) path.Path
getItem func(t *testing.T, itemName string) data.Item 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)) require.NoError(t, err, clues.ToCore(err))
info := &details.SharePointInfo{ info := &details.SharePointInfo{
ItemName: name, List: &details.ListInfo{
Name: name,
},
} }
data, err := data.NewPrefetchedItemWithInfo( data, err := data.NewPrefetchedItemWithInfo(
@ -194,7 +196,10 @@ func (suite *SharePointCollectionSuite) TestPrefetchCollection_Items() {
assert.NotNil(t, info) assert.NotNil(t, info)
assert.NotNil(t, info.SharePoint) 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)
}
}) })
} }
} }

View File

@ -168,7 +168,7 @@ func deleteList(
assert.NoError(t, err, "getting site lists", clues.ToCore(err)) assert.NoError(t, err, "getting site lists", clues.ToCore(err))
for _, l := range lists { for _, l := range lists {
if ptr.Val(l.GetDisplayName()) == deets.SharePoint.ItemName { if ptr.Val(l.GetDisplayName()) == deets.SharePoint.List.Name {
isFound = true isFound = true
deleteID = ptr.Val(l.GetId()) deleteID = ptr.Val(l.GetId())