mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 23:55:33 -05:00
Merge pull request #21998 from overleaf/ar-fix-flaky-project-archive-test
[history-v1] Handle race condition in project archive test GitOrigin-RevId: c32f4646f08223da0ed42068fa3fb613a6595b95
This commit is contained in:
parent
623d88bee0
commit
adecf0d5fe
1 changed files with 8 additions and 4 deletions
|
@ -121,7 +121,7 @@ describe('ProjectArchive', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
const testStream = new stream.Readable({
|
const testStream = new stream.Readable({
|
||||||
read: function () {
|
read: function () {
|
||||||
testStream.emit('error', new Error('test read error'))
|
testStream.destroy(new Error('test read error'))
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
sinon.stub(blobStore, 'getStream').resolves(testStream)
|
sinon.stub(blobStore, 'getStream').resolves(testStream)
|
||||||
|
@ -141,7 +141,11 @@ describe('ProjectArchive', function () {
|
||||||
expect.fail()
|
expect.fail()
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
expect(err.message).to.match(/test read error/)
|
let message = err.message
|
||||||
|
if (err instanceof ProjectArchive.DownloadError) {
|
||||||
|
message = err.cause.message
|
||||||
|
}
|
||||||
|
expect(message).to.match(/test read error/)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -150,8 +154,8 @@ describe('ProjectArchive', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
sinon.stub(fs, 'createWriteStream').callsFake(path => {
|
sinon.stub(fs, 'createWriteStream').callsFake(path => {
|
||||||
const testStream = new stream.Writable({
|
const testStream = new stream.Writable({
|
||||||
write: function () {
|
write: function (chunk, encoding, callback) {
|
||||||
testStream.emit('error', new Error('test write error'))
|
callback(new Error('test write error'))
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
return testStream
|
return testStream
|
||||||
|
|
Loading…
Reference in a new issue