Utilize mock backup handler

This commit is contained in:
Abhishek Pandey 2023-06-01 15:15:46 -07:00
parent c13f70ecc7
commit 30e9439287
3 changed files with 9 additions and 7 deletions

View File

@ -613,7 +613,8 @@ type mockURLCache struct {
func (muc *mockURLCache) getItemProperties(
ctx context.Context,
itemID string) (itemProps, error) {
itemID string,
) (itemProps, error) {
return muc.Get(ctx, itemID)
}

View File

@ -391,7 +391,6 @@ func (c *Collections) Get(
err = c.addURLCacheToDriveCollections(
ictx,
driveID,
c.handler.ItemPager(driveID, "", api.DriveItemSelectDefault()),
errs)
if err != nil {
return nil, err
@ -459,17 +458,18 @@ func (c *Collections) Get(
return collections, canUsePreviousBackup, nil
}
// addURLCacheToDriveCollections adds a URL cache to all collections belonging to
// a drive.
func (c *Collections) addURLCacheToDriveCollections(
ctx context.Context,
driveID string,
pager api.DriveItemEnumerator,
errs *fault.Bus,
) error {
uc, err := newURLCache(
driveID,
urlCacheRefreshInterval,
errs,
pager)
c.handler.ItemPager(driveID, "", api.DriveItemSelectDefault()))
if err != nil {
return err
}

View File

@ -2692,7 +2692,6 @@ func (suite *OneDriveCollectionsUnitSuite) TestURLCacheIntegration() {
prevDelta string
err error
}{
{
name: "cache is attached",
},
@ -2704,8 +2703,11 @@ func (suite *OneDriveCollectionsUnitSuite) TestURLCacheIntegration() {
ctx, flush := tester.NewContext()
defer flush()
mbh := mock.DefaultOneDriveBH()
mbh.ItemPagerV = map[string]api.DriveItemEnumerator{}
c := NewCollections(
&itemBackupHandler{api.Drives{}},
mbh,
"test-tenant",
"test-user",
testFolderMatcher{(&selectors.OneDriveBackup{}).Folders(selectors.Any())[0]},
@ -2737,7 +2739,6 @@ func (suite *OneDriveCollectionsUnitSuite) TestURLCacheIntegration() {
err := c.addURLCacheToDriveCollections(
ctx,
driveID,
&mockItemPager{},
fault.New(true))
require.NoError(t, err, clues.ToCore(err))