Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change kopia location directory from list name to id #4893

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/internal/m365/collection/site/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func CollectPages(
su,
bpc.Options)
collection.SetBetaService(betaService)
collection.AddJob(tuple.ID)
collection.AddItem(tuple.ID)

spcs = append(spcs, collection)
}
Expand Down Expand Up @@ -173,7 +173,7 @@ func CollectLists(
path.SharePointService,
path.ListsCategory,
false,
ptr.Val(list.GetDisplayName()))
ptr.Val(list.GetId()))
if err != nil {
el.AddRecoverable(ctx, clues.WrapWC(ctx, err, "creating list collection path"))
}
Expand All @@ -185,7 +185,7 @@ func CollectLists(
scope,
su,
bpc.Options)
collection.AddJob(ptr.Val(list.GetId()))
collection.AddItem(ptr.Val(list.GetId()))

spcs = append(spcs, collection)
}
Expand Down
6 changes: 3 additions & 3 deletions src/internal/m365/collection/site/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ func (sc *Collection) SetBetaService(betaService *betaAPI.BetaService) {
sc.betaService = betaService
}

// AddJob appends additional objectID to job field
func (sc *Collection) AddJob(objID string) {
sc.items = append(sc.items, objID)
// AddItem appends additional itemID to items field
func (sc *Collection) AddItem(itemID string) {
sc.items = append(sc.items, itemID)
}

func (sc *Collection) FullPath() path.Path {
Expand Down
39 changes: 34 additions & 5 deletions src/pkg/backup/details/details_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1338,12 +1338,16 @@ func (suite *DetailsUnitSuite) TestUnarshalTo() {

func (suite *DetailsUnitSuite) TestLocationIDer_FromEntry() {
const (
rrString = "tenant-id/%s/user-id/%s/drives/drive-id/root:/some/folder/stuff/item"
driveID = "driveID"
rrString = "tenant-id/%s/user-id/%s/drives/drive-id/root:/some/folder/stuff/item"
listsRrString = "tenant-id/%s/site-id/%s/lists/list-id/list-id"
driveID = "driveID"
listID = "listID"

expectedUniqueLocFmt = "%s/" + driveID + "/root:/some/folder/stuff"
expectedExchangeUniqueLocFmt = "%s/root:/some/folder/stuff"
expectedDetailsLoc = "root:/some/folder/stuff"
expectedListUniqueLocFmt = "%s/" + listID
expectedListDetailsLoc = listID
)

table := []struct {
Expand Down Expand Up @@ -1440,6 +1444,21 @@ func (suite *DetailsUnitSuite) TestLocationIDer_FromEntry() {
backupVersion: version.OneDrive7LocationRef,
expectedErr: require.Error,
},
{
name: "SharePoint List With LocationRef",
service: path.SharePointService.String(),
category: path.ListsCategory.String(),
itemInfo: ItemInfo{
SharePoint: &SharePointInfo{
ItemType: SharePointList,
List: &ListInfo{},
},
},
backupVersion: version.OneDrive7LocationRef,
hasLocRef: true,
expectedErr: require.NoError,
expectedUniqueLoc: fmt.Sprintf(expectedListUniqueLocFmt, path.ListsCategory),
},
{
name: "Exchange Email With LocationRef Old Version",
service: path.ExchangeService.String(),
Expand Down Expand Up @@ -1540,13 +1559,23 @@ func (suite *DetailsUnitSuite) TestLocationIDer_FromEntry() {
suite.Run(test.name, func() {
t := suite.T()

rr := ""
detailsLoc := ""
if test.category == path.ListsCategory.String() {
rr = fmt.Sprintf(listsRrString, test.service, test.category)
detailsLoc = expectedListDetailsLoc
} else {
rr = fmt.Sprintf(rrString, test.service, test.category)
detailsLoc = expectedDetailsLoc
}

entry := Entry{
RepoRef: fmt.Sprintf(rrString, test.service, test.category),
RepoRef: rr,
ItemInfo: test.itemInfo,
}

if test.hasLocRef {
entry.LocationRef = expectedDetailsLoc
entry.LocationRef = detailsLoc
}

loc, err := entry.ToLocationIDer(test.backupVersion)
Expand All @@ -1563,7 +1592,7 @@ func (suite *DetailsUnitSuite) TestLocationIDer_FromEntry() {
"unique location")
assert.Equal(
t,
expectedDetailsLoc,
detailsLoc,
loc.InDetails().String(),
"details location")
})
Expand Down
4 changes: 3 additions & 1 deletion src/pkg/services/m365/api/lists_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ func (suite *ListsUnitSuite) TestSharePointInfo() {
info := ListToSPInfo(list)
assert.Equal(t, expected.ItemType, info.ItemType)
assert.Equal(t, expected.ItemName, info.ItemName)
assert.Equal(t, expected.List.ItemCount, info.List.ItemCount)
assert.Equal(t, expected.WebURL, info.WebURL)
if expected.List != nil {
assert.Equal(t, expected.List.ItemCount, info.List.ItemCount)
}
})
}
}
Expand Down
Loading