Add soem more tests
This commit is contained in:
parent
30e9439287
commit
34e1f393cb
@ -692,7 +692,7 @@ func (suite *GetDriveItemUnitTestSuite) TestDownloadContent() {
|
|||||||
muc: m,
|
muc: m,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "expired url fetched from cache",
|
name: "url refreshed from cache",
|
||||||
mgi: mock.GetsItem{Item: itemWID, Err: nil},
|
mgi: mock.GetsItem{Item: itemWID, Err: nil},
|
||||||
itemInfo: details.ItemInfo{},
|
itemInfo: details.ItemInfo{},
|
||||||
respBody: []io.ReadCloser{nil, iorc},
|
respBody: []io.ReadCloser{nil, iorc},
|
||||||
@ -710,11 +710,11 @@ func (suite *GetDriveItemUnitTestSuite) TestDownloadContent() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "expired url fetched from cache but item deleted",
|
name: "url refreshed from cache but item deleted",
|
||||||
mgi: mock.GetsItem{Item: itemWID, Err: assert.AnError},
|
mgi: mock.GetsItem{Item: itemWID, Err: graph.ErrDeletedInFlight},
|
||||||
itemInfo: details.ItemInfo{},
|
itemInfo: details.ItemInfo{},
|
||||||
respBody: []io.ReadCloser{nil, nil},
|
respBody: []io.ReadCloser{nil, nil, nil},
|
||||||
getErr: []error{errUnauth, assert.AnError},
|
getErr: []error{errUnauth, graph.ErrDeletedInFlight, graph.ErrDeletedInFlight},
|
||||||
expectErr: require.Error,
|
expectErr: require.Error,
|
||||||
expect: require.Nil,
|
expect: require.Nil,
|
||||||
muc: &mockURLCache{
|
muc: &mockURLCache{
|
||||||
@ -727,6 +727,20 @@ func (suite *GetDriveItemUnitTestSuite) TestDownloadContent() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "fallback to item fetch on any cache error",
|
||||||
|
mgi: mock.GetsItem{Item: itemWID, Err: nil},
|
||||||
|
itemInfo: details.ItemInfo{},
|
||||||
|
respBody: []io.ReadCloser{nil, iorc},
|
||||||
|
getErr: []error{errUnauth, nil},
|
||||||
|
expectErr: require.NoError,
|
||||||
|
expect: require.NotNil,
|
||||||
|
muc: &mockURLCache{
|
||||||
|
Get: func(ctx context.Context, itemID string) (itemProps, error) {
|
||||||
|
return itemProps{}, assert.AnError
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
suite.Run(test.name, func() {
|
suite.Run(test.name, func() {
|
||||||
@ -755,7 +769,7 @@ func (suite *GetDriveItemUnitTestSuite) TestDownloadContent() {
|
|||||||
mbh,
|
mbh,
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
"drive-id",
|
driveID,
|
||||||
nil,
|
nil,
|
||||||
control.Options{ToggleFeatures: control.Toggles{}},
|
control.Options{ToggleFeatures: control.Toggles{}},
|
||||||
CollectionScopeFolder,
|
CollectionScopeFolder,
|
||||||
|
|||||||
@ -384,7 +384,6 @@ func (c *Collections) Get(
|
|||||||
numPrevItems = c.NumItems
|
numPrevItems = c.NumItems
|
||||||
|
|
||||||
// Only create a drive cache if there are less than 300k items in the drive.
|
// Only create a drive cache if there are less than 300k items in the drive.
|
||||||
// TODO: Tune this number. Delta query for 300k items takes ~20 mins.
|
|
||||||
if numDriveItems < urlCacheDriveItemThreshold {
|
if numDriveItems < urlCacheDriveItemThreshold {
|
||||||
logger.Ctx(ictx).Info("adding url cache for drive ", driveID)
|
logger.Ctx(ictx).Info("adding url cache for drive ", driveID)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user