Utilize mock backup handler
This commit is contained in:
parent
c13f70ecc7
commit
30e9439287
@ -613,7 +613,8 @@ type mockURLCache struct {
|
|||||||
|
|
||||||
func (muc *mockURLCache) getItemProperties(
|
func (muc *mockURLCache) getItemProperties(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
itemID string) (itemProps, error) {
|
itemID string,
|
||||||
|
) (itemProps, error) {
|
||||||
return muc.Get(ctx, itemID)
|
return muc.Get(ctx, itemID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -391,7 +391,6 @@ func (c *Collections) Get(
|
|||||||
err = c.addURLCacheToDriveCollections(
|
err = c.addURLCacheToDriveCollections(
|
||||||
ictx,
|
ictx,
|
||||||
driveID,
|
driveID,
|
||||||
c.handler.ItemPager(driveID, "", api.DriveItemSelectDefault()),
|
|
||||||
errs)
|
errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -459,17 +458,18 @@ func (c *Collections) Get(
|
|||||||
return collections, canUsePreviousBackup, nil
|
return collections, canUsePreviousBackup, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// addURLCacheToDriveCollections adds a URL cache to all collections belonging to
|
||||||
|
// a drive.
|
||||||
func (c *Collections) addURLCacheToDriveCollections(
|
func (c *Collections) addURLCacheToDriveCollections(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
driveID string,
|
driveID string,
|
||||||
pager api.DriveItemEnumerator,
|
|
||||||
errs *fault.Bus,
|
errs *fault.Bus,
|
||||||
) error {
|
) error {
|
||||||
uc, err := newURLCache(
|
uc, err := newURLCache(
|
||||||
driveID,
|
driveID,
|
||||||
urlCacheRefreshInterval,
|
urlCacheRefreshInterval,
|
||||||
errs,
|
errs,
|
||||||
pager)
|
c.handler.ItemPager(driveID, "", api.DriveItemSelectDefault()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2692,7 +2692,6 @@ func (suite *OneDriveCollectionsUnitSuite) TestURLCacheIntegration() {
|
|||||||
prevDelta string
|
prevDelta string
|
||||||
err error
|
err error
|
||||||
}{
|
}{
|
||||||
|
|
||||||
{
|
{
|
||||||
name: "cache is attached",
|
name: "cache is attached",
|
||||||
},
|
},
|
||||||
@ -2704,8 +2703,11 @@ func (suite *OneDriveCollectionsUnitSuite) TestURLCacheIntegration() {
|
|||||||
ctx, flush := tester.NewContext()
|
ctx, flush := tester.NewContext()
|
||||||
defer flush()
|
defer flush()
|
||||||
|
|
||||||
|
mbh := mock.DefaultOneDriveBH()
|
||||||
|
mbh.ItemPagerV = map[string]api.DriveItemEnumerator{}
|
||||||
|
|
||||||
c := NewCollections(
|
c := NewCollections(
|
||||||
&itemBackupHandler{api.Drives{}},
|
mbh,
|
||||||
"test-tenant",
|
"test-tenant",
|
||||||
"test-user",
|
"test-user",
|
||||||
testFolderMatcher{(&selectors.OneDriveBackup{}).Folders(selectors.Any())[0]},
|
testFolderMatcher{(&selectors.OneDriveBackup{}).Folders(selectors.Any())[0]},
|
||||||
@ -2737,7 +2739,6 @@ func (suite *OneDriveCollectionsUnitSuite) TestURLCacheIntegration() {
|
|||||||
err := c.addURLCacheToDriveCollections(
|
err := c.addURLCacheToDriveCollections(
|
||||||
ctx,
|
ctx,
|
||||||
driveID,
|
driveID,
|
||||||
&mockItemPager{},
|
|
||||||
fault.New(true))
|
fault.New(true))
|
||||||
|
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user