mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Merge pull request #4866 from overleaf/bg-gcs-delete-directory-batch
make object-persistor delete gcs files in batches GitOrigin-RevId: 8ebc892c5f6eb30507ec41d5d3a108e650af5cac
This commit is contained in:
@@ -556,18 +556,30 @@ describe('GcsPersistorTests', function () {
|
||||
const directoryName = `${ObjectId()}/${ObjectId()}`
|
||||
describe('with valid parameters', function () {
|
||||
beforeEach(async function () {
|
||||
GcsBucket.getFiles = sinon.stub()
|
||||
// set up multiple paginated calls to getFiles
|
||||
GcsBucket.getFiles
|
||||
.withArgs({ directory: directoryName, autoPaginate: false })
|
||||
.resolves([['aaa', 'bbb'], 'call-1'])
|
||||
GcsBucket.getFiles
|
||||
.withArgs('call-1')
|
||||
.resolves([['ccc', 'ddd', 'eee'], 'call-2'])
|
||||
GcsBucket.getFiles.withArgs('call-2').resolves([['fff', 'ggg']])
|
||||
return GcsPersistor.deleteDirectory(bucket, directoryName)
|
||||
})
|
||||
|
||||
it('should list the objects in the directory', function () {
|
||||
expect(Storage.prototype.bucket).to.have.been.calledWith(bucket)
|
||||
expect(GcsBucket.getFiles).to.have.been.calledWith({
|
||||
directory: directoryName
|
||||
directory: directoryName,
|
||||
autoPaginate: false
|
||||
})
|
||||
expect(GcsBucket.getFiles).to.have.been.calledWith('call-1')
|
||||
expect(GcsBucket.getFiles).to.have.been.calledWith('call-2')
|
||||
})
|
||||
|
||||
it('should delete the files', function () {
|
||||
expect(GcsFile.delete).to.have.been.calledTwice
|
||||
expect(GcsFile.delete.callCount).to.equal(7)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user