mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
e0dba75b81
GitOrigin-RevId: ab45010ec557d62576c470d2e024549e67261c66
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
import { spawnSync } from 'child_process'
|
|
import { expect } from 'chai'
|
|
import { db, ObjectId } from '../../../app/src/infrastructure/mongodb.js'
|
|
|
|
describe('BatchedUpdateTests', function () {
|
|
it('can handle non linear insert order', async function () {
|
|
await db.systemmessages.insertOne({
|
|
content: '1',
|
|
_id: new ObjectId('500000000000000000000000'),
|
|
})
|
|
await db.systemmessages.insertOne({
|
|
content: '2',
|
|
_id: new ObjectId('400000000000000000000000'),
|
|
})
|
|
await db.systemmessages.insertOne({
|
|
content: '3',
|
|
_id: new ObjectId('600000000000000000000000'),
|
|
})
|
|
await db.systemmessages.insertOne({
|
|
content: '4',
|
|
_id: new ObjectId('300000000000000000000000'),
|
|
})
|
|
|
|
spawnSync(process.argv0, [
|
|
'-e',
|
|
'require("./scripts/helpers/batchedUpdate").batchedUpdateWithResultHandling("systemmessages", { content: { $ne: "42" }}, { $set: { content: "42" } })',
|
|
])
|
|
|
|
await expect(
|
|
db.systemmessages.find({}).project({ content: 1, _id: 0 }).toArray()
|
|
).to.eventually.deep.equal([
|
|
{ content: '42' },
|
|
{ content: '42' },
|
|
{ content: '42' },
|
|
{ content: '42' },
|
|
])
|
|
})
|
|
})
|