Fix runDriveRestoreWithAdvancedOptions

This commit is contained in:
Abin Simon 2023-10-17 17:24:24 +05:30
parent 9a647aa422
commit 4a2dc774b3
3 changed files with 15 additions and 18 deletions

View File

@ -222,8 +222,7 @@ func (suite *GroupsRestoreNightlyIntgSuite) TestRestore_Run_groupsWithAdvancedOp
suite, suite,
suite.its.ac, suite.its.ac,
sel.Selector, sel.Selector,
suite.its.group.RootSite.DriveID, suite.its.group.RootSite)
suite.its.group.RootSite.DriveRootFolderID)
} }
func (suite *GroupsRestoreNightlyIntgSuite) TestRestore_Run_groupsAlternateProtectedResource() { func (suite *GroupsRestoreNightlyIntgSuite) TestRestore_Run_groupsAlternateProtectedResource() {

View File

@ -1015,8 +1015,7 @@ func (suite *OneDriveRestoreNightlyIntgSuite) TestRestore_Run_onedriveWithAdvanc
suite, suite,
suite.its.ac, suite.its.ac,
sel.Selector, sel.Selector,
suite.its.user.DriveID, suite.its.user)
suite.its.user.DriveRootFolderID)
} }
func runDriveRestoreWithAdvancedOptions( func runDriveRestoreWithAdvancedOptions(
@ -1024,7 +1023,7 @@ func runDriveRestoreWithAdvancedOptions(
suite tester.Suite, suite tester.Suite,
ac api.Client, ac api.Client,
sel selectors.Selector, // both Restore and Backup types work. sel selectors.Selector, // both Restore and Backup types work.
driveID, rootFolderID string, driveFrom ids,
) { ) {
ctx, flush := tester.NewContext(t) ctx, flush := tester.NewContext(t)
defer flush() defer flush()
@ -1053,7 +1052,7 @@ func runDriveRestoreWithAdvancedOptions(
// Groups restore needs subservice information // Groups restore needs subservice information
if sel.Service == selectors.ServiceGroups { if sel.Service == selectors.ServiceGroups {
restoreCfg.SubService.Type = path.SharePointService restoreCfg.SubService.Type = path.SharePointService
restoreCfg.SubService.ID = driveID restoreCfg.SubService.ID = driveFrom.ID
} }
// initial restore // initial restore
@ -1084,18 +1083,18 @@ func runDriveRestoreWithAdvancedOptions(
// get all files in folder, use these as the base // get all files in folder, use these as the base
// set of files to compare against. // set of files to compare against.
contGC, err := acd.GetFolderByName(ctx, driveID, rootFolderID, restoreCfg.Location) contGC, err := acd.GetFolderByName(ctx, driveFrom.DriveID, driveFrom.DriveRootFolderID, restoreCfg.Location)
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
// the folder containing the files is a child of the folder created by the restore. // the folder containing the files is a child of the folder created by the restore.
contGC, err = acd.GetFolderByName(ctx, driveID, ptr.Val(contGC.GetId()), selTD.TestFolderName) contGC, err = acd.GetFolderByName(ctx, driveFrom.DriveID, ptr.Val(contGC.GetId()), selTD.TestFolderName)
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
containerID = ptr.Val(contGC.GetId()) containerID = ptr.Val(contGC.GetId())
collKeys, err = acd.GetItemsInContainerByCollisionKey( collKeys, err = acd.GetItemsInContainerByCollisionKey(
ctx, ctx,
driveID, driveFrom.DriveID,
containerID) containerID)
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
@ -1103,7 +1102,7 @@ func runDriveRestoreWithAdvancedOptions(
checkRestoreCounts(t, ctr, 0, 0, countItemsInRestore) checkRestoreCounts(t, ctr, 0, 0, countItemsInRestore)
fileIDs, err = acd.GetItemIDsInContainer(ctx, driveID, containerID) fileIDs, err = acd.GetItemIDsInContainer(ctx, driveFrom.DriveID, containerID)
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
}) })
@ -1145,14 +1144,14 @@ func runDriveRestoreWithAdvancedOptions(
result := filterCollisionKeyResults( result := filterCollisionKeyResults(
t, t,
ctx, ctx,
driveID, driveFrom.DriveID,
containerID, containerID,
GetItemsInContainerByCollisionKeyer[api.DriveItemIDType](acd), GetItemsInContainerByCollisionKeyer[api.DriveItemIDType](acd),
collKeys) collKeys)
assert.Len(t, result, 0, "no new items should get added") assert.Len(t, result, 0, "no new items should get added")
currentFileIDs, err := acd.GetItemIDsInContainer(ctx, driveID, containerID) currentFileIDs, err := acd.GetItemIDsInContainer(ctx, driveFrom.DriveID, containerID)
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
assert.Equal(t, fileIDs, currentFileIDs, "ids are equal") assert.Equal(t, fileIDs, currentFileIDs, "ids are equal")
@ -1201,7 +1200,7 @@ func runDriveRestoreWithAdvancedOptions(
result := filterCollisionKeyResults( result := filterCollisionKeyResults(
t, t,
ctx, ctx,
driveID, driveFrom.DriveID,
containerID, containerID,
GetItemsInContainerByCollisionKeyer[api.DriveItemIDType](acd), GetItemsInContainerByCollisionKeyer[api.DriveItemIDType](acd),
collKeys) collKeys)
@ -1212,7 +1211,7 @@ func runDriveRestoreWithAdvancedOptions(
assert.NotEqual(t, v, collKeys[k], "replaced items should have new IDs") assert.NotEqual(t, v, collKeys[k], "replaced items should have new IDs")
} }
currentFileIDs, err := acd.GetItemIDsInContainer(ctx, driveID, containerID) currentFileIDs, err := acd.GetItemIDsInContainer(ctx, driveFrom.DriveID, containerID)
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
assert.Equal(t, len(fileIDs), len(currentFileIDs), "count of ids ids are equal") assert.Equal(t, len(fileIDs), len(currentFileIDs), "count of ids ids are equal")
@ -1266,14 +1265,14 @@ func runDriveRestoreWithAdvancedOptions(
result := filterCollisionKeyResults( result := filterCollisionKeyResults(
t, t,
ctx, ctx,
driveID, driveFrom.DriveID,
containerID, containerID,
GetItemsInContainerByCollisionKeyer[api.DriveItemIDType](acd), GetItemsInContainerByCollisionKeyer[api.DriveItemIDType](acd),
collKeys) collKeys)
assert.Len(t, result, len(collKeys), "all items should have been added as copies") assert.Len(t, result, len(collKeys), "all items should have been added as copies")
currentFileIDs, err := acd.GetItemIDsInContainer(ctx, driveID, containerID) currentFileIDs, err := acd.GetItemIDsInContainer(ctx, driveFrom.DriveID, containerID)
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
assert.Equal(t, 2*len(fileIDs), len(currentFileIDs), "count of ids should be double from before") assert.Equal(t, 2*len(fileIDs), len(currentFileIDs), "count of ids should be double from before")

View File

@ -209,8 +209,7 @@ func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointWithAd
suite, suite,
suite.its.ac, suite.its.ac,
sel.Selector, sel.Selector,
suite.its.site.DriveID, suite.its.site)
suite.its.site.DriveRootFolderID)
} }
func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointAlternateProtectedResource() { func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointAlternateProtectedResource() {