mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
Merge pull request #10245 from overleaf/em-object-persistor-promises-api
Use Node 16 promises APIs in object-persistor GitOrigin-RevId: 8520da0c0678c17b22a9164d15d61c2b57af8f4e
This commit is contained in:
@@ -26,6 +26,7 @@ describe('GcsPersistorTests', function () {
|
||||
GcsNotFoundError,
|
||||
ReadStream,
|
||||
Stream,
|
||||
StreamPromises,
|
||||
GcsBucket,
|
||||
GcsFile,
|
||||
GcsPersistor,
|
||||
@@ -78,10 +79,13 @@ describe('GcsPersistorTests', function () {
|
||||
}
|
||||
|
||||
Stream = {
|
||||
pipeline: sinon.stub().yields(),
|
||||
Transform,
|
||||
}
|
||||
|
||||
StreamPromises = {
|
||||
pipeline: sinon.stub().resolves(),
|
||||
}
|
||||
|
||||
GcsFile = {
|
||||
delete: sinon.stub().resolves(),
|
||||
createReadStream: sinon.stub().returns(ReadStream),
|
||||
@@ -136,6 +140,7 @@ describe('GcsPersistorTests', function () {
|
||||
'./Errors': Errors,
|
||||
fs: Fs,
|
||||
stream: Stream,
|
||||
'stream/promises': StreamPromises,
|
||||
crypto,
|
||||
},
|
||||
globals: { console, Buffer },
|
||||
@@ -373,7 +378,7 @@ describe('GcsPersistorTests', function () {
|
||||
})
|
||||
|
||||
it('should meter the stream and pass it to GCS', function () {
|
||||
expect(Stream.pipeline).to.have.been.calledWith(
|
||||
expect(StreamPromises.pipeline).to.have.been.calledWith(
|
||||
ReadStream,
|
||||
sinon.match.instanceOf(Transform),
|
||||
WriteStream
|
||||
@@ -433,14 +438,9 @@ describe('GcsPersistorTests', function () {
|
||||
describe('when the upload fails', function () {
|
||||
let error
|
||||
beforeEach(async function () {
|
||||
Stream.pipeline
|
||||
.withArgs(
|
||||
ReadStream,
|
||||
sinon.match.instanceOf(Transform),
|
||||
WriteStream,
|
||||
sinon.match.any
|
||||
)
|
||||
.yields(genericError)
|
||||
StreamPromises.pipeline
|
||||
.withArgs(ReadStream, sinon.match.instanceOf(Transform), WriteStream)
|
||||
.rejects(genericError)
|
||||
try {
|
||||
await GcsPersistor.sendStream(bucket, key, ReadStream)
|
||||
} catch (err) {
|
||||
@@ -475,7 +475,7 @@ describe('GcsPersistorTests', function () {
|
||||
})
|
||||
|
||||
it('should upload the stream via the meter', function () {
|
||||
expect(Stream.pipeline).to.have.been.calledWith(
|
||||
expect(StreamPromises.pipeline).to.have.been.calledWith(
|
||||
ReadStream,
|
||||
sinon.match.instanceOf(Transform),
|
||||
WriteStream
|
||||
|
||||
Reference in New Issue
Block a user