mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
Merge pull request #21375 from overleaf/jpa-if-none-match
[object-persistor] add support for ifNoneMatch=* in sendStream GitOrigin-RevId: 268f054ac1b6452105b02757cdec32bad00702fd
This commit is contained in:
@@ -32,6 +32,10 @@ process.on('unhandledRejection', e => {
|
||||
// store settings for multiple backends, so that we can test each one.
|
||||
// fs will always be available - add others if they are configured
|
||||
const { BackendSettings, s3Config } = require('./TestConfig')
|
||||
const {
|
||||
AlreadyWrittenError,
|
||||
NotImplementedError,
|
||||
} = require('@overleaf/object-persistor/src/Errors')
|
||||
|
||||
describe('Filestore', function () {
|
||||
this.timeout(1000 * 10)
|
||||
@@ -273,6 +277,40 @@ describe('Filestore', function () {
|
||||
expect(body).to.equal(newContent)
|
||||
})
|
||||
|
||||
describe('IfNoneMatch', function () {
|
||||
if (backendSettings.backend === 'fs') {
|
||||
it('should refuse to handle IfNoneMatch', async function () {
|
||||
await expect(
|
||||
app.persistor.sendStream(
|
||||
Settings.filestore.stores.user_files,
|
||||
`${projectId}/${fileId}`,
|
||||
fs.createReadStream(localFileReadPath),
|
||||
{ ifNoneMatch: '*' }
|
||||
)
|
||||
).to.be.rejectedWith(NotImplementedError)
|
||||
})
|
||||
} else {
|
||||
it('should reject sendStream on the same key with IfNoneMatch', async function () {
|
||||
await expect(
|
||||
app.persistor.sendStream(
|
||||
Settings.filestore.stores.user_files,
|
||||
`${projectId}/${fileId}`,
|
||||
fs.createReadStream(localFileReadPath),
|
||||
{ ifNoneMatch: '*' }
|
||||
)
|
||||
).to.be.rejectedWith(AlreadyWrittenError)
|
||||
})
|
||||
it('should allow sendStream on a different key with IfNoneMatch', async function () {
|
||||
await app.persistor.sendStream(
|
||||
Settings.filestore.stores.user_files,
|
||||
`${projectId}/${fileId}-other`,
|
||||
fs.createReadStream(localFileReadPath),
|
||||
{ ifNoneMatch: '*' }
|
||||
)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
if (backendSettings.backend !== 'fs') {
|
||||
it('should record an egress metric for the upload', async function () {
|
||||
const metric = await TestHelper.getMetric(
|
||||
|
||||
Reference in New Issue
Block a user