2020-02-16 09:02:55 -05:00
|
|
|
const SandboxedModule = require('sandboxed-module')
|
|
|
|
const sinon = require('sinon')
|
2024-11-08 05:21:56 -05:00
|
|
|
const modulePath = require('node:path').join(
|
2020-02-16 09:02:55 -05:00
|
|
|
__dirname,
|
|
|
|
'../../../app/js/MongoManager'
|
|
|
|
)
|
2024-07-15 07:10:48 -04:00
|
|
|
const { ObjectId } = require('mongodb-legacy')
|
2022-04-26 07:16:36 -04:00
|
|
|
const { assert, expect } = require('chai')
|
2021-07-30 11:06:16 -04:00
|
|
|
const Errors = require('../../../app/js/Errors')
|
2020-02-16 09:02:55 -05:00
|
|
|
|
2020-05-28 09:20:54 -04:00
|
|
|
describe('MongoManager', function () {
|
|
|
|
beforeEach(function () {
|
2022-04-26 07:16:36 -04:00
|
|
|
this.db = {
|
|
|
|
docs: {
|
2024-01-18 08:00:51 -05:00
|
|
|
updateOne: sinon.stub().resolves({ matchedCount: 1 }),
|
|
|
|
insertOne: sinon.stub().resolves(),
|
2022-04-26 07:16:36 -04:00
|
|
|
},
|
|
|
|
}
|
2020-02-16 09:02:55 -05:00
|
|
|
this.MongoManager = SandboxedModule.require(modulePath, {
|
|
|
|
requires: {
|
2020-08-21 12:50:01 -04:00
|
|
|
'./mongodb': {
|
2022-04-26 07:16:36 -04:00
|
|
|
db: this.db,
|
2021-07-13 07:04:48 -04:00
|
|
|
ObjectId,
|
2020-02-16 09:02:55 -05:00
|
|
|
},
|
2022-05-17 07:49:13 -04:00
|
|
|
'@overleaf/settings': {
|
|
|
|
max_deleted_docs: 42,
|
|
|
|
docstore: { archivingLockDurationMs: 5000 },
|
|
|
|
},
|
2021-08-02 06:36:43 -04:00
|
|
|
'./Errors': Errors,
|
2021-07-13 07:04:48 -04:00
|
|
|
},
|
2020-02-16 09:02:55 -05:00
|
|
|
})
|
2023-12-13 04:38:54 -05:00
|
|
|
this.projectId = new ObjectId().toString()
|
|
|
|
this.docId = new ObjectId().toString()
|
2023-03-22 09:08:01 -04:00
|
|
|
this.rev = 42
|
2022-04-19 08:28:47 -04:00
|
|
|
this.stubbedErr = new Error('hello world')
|
2023-11-15 07:30:14 -05:00
|
|
|
this.lines = ['Three French hens', 'Two turtle doves']
|
2020-02-16 09:02:55 -05:00
|
|
|
})
|
|
|
|
|
2020-05-28 09:20:54 -04:00
|
|
|
describe('findDoc', function () {
|
2024-01-18 08:00:51 -05:00
|
|
|
beforeEach(async function () {
|
2020-02-16 09:02:55 -05:00
|
|
|
this.doc = { name: 'mock-doc' }
|
2024-01-18 08:00:51 -05:00
|
|
|
this.db.docs.findOne = sinon.stub().resolves(this.doc)
|
2020-02-16 09:02:55 -05:00
|
|
|
this.filter = { lines: true }
|
2024-01-18 08:00:51 -05:00
|
|
|
this.result = await this.MongoManager.promises.findDoc(
|
2022-04-26 07:16:36 -04:00
|
|
|
this.projectId,
|
|
|
|
this.docId,
|
2024-01-18 08:00:51 -05:00
|
|
|
this.filter
|
2020-02-16 09:02:55 -05:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2020-05-28 09:20:54 -04:00
|
|
|
it('should find the doc', function () {
|
2020-08-21 12:50:01 -04:00
|
|
|
this.db.docs.findOne
|
2020-02-16 09:02:55 -05:00
|
|
|
.calledWith(
|
|
|
|
{
|
2023-12-13 04:38:54 -05:00
|
|
|
_id: new ObjectId(this.docId),
|
|
|
|
project_id: new ObjectId(this.projectId),
|
2020-02-16 09:02:55 -05:00
|
|
|
},
|
2020-09-07 05:16:12 -04:00
|
|
|
{
|
2021-07-13 07:04:48 -04:00
|
|
|
projection: this.filter,
|
2020-09-07 05:16:12 -04:00
|
|
|
}
|
2020-02-16 09:02:55 -05:00
|
|
|
)
|
|
|
|
.should.equal(true)
|
|
|
|
})
|
|
|
|
|
2024-01-18 08:00:51 -05:00
|
|
|
it('should return the doc', function () {
|
|
|
|
expect(this.doc).to.deep.equal(this.doc)
|
2020-02-16 09:02:55 -05:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-02-15 08:13:48 -05:00
|
|
|
describe('patchDoc', function () {
|
2024-01-18 08:00:51 -05:00
|
|
|
beforeEach(async function () {
|
2021-02-15 08:13:48 -05:00
|
|
|
this.meta = { name: 'foo.tex' }
|
2024-01-18 08:00:51 -05:00
|
|
|
await this.MongoManager.promises.patchDoc(
|
2022-04-26 07:16:36 -04:00
|
|
|
this.projectId,
|
|
|
|
this.docId,
|
2024-01-18 08:00:51 -05:00
|
|
|
this.meta
|
2021-02-15 08:13:48 -05:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should pass the parameter along', function () {
|
|
|
|
this.db.docs.updateOne.should.have.been.calledWith(
|
|
|
|
{
|
2023-12-13 04:38:54 -05:00
|
|
|
_id: new ObjectId(this.docId),
|
|
|
|
project_id: new ObjectId(this.projectId),
|
2021-02-15 08:13:48 -05:00
|
|
|
},
|
|
|
|
{
|
2021-07-13 07:04:48 -04:00
|
|
|
$set: this.meta,
|
2024-01-18 08:00:51 -05:00
|
|
|
}
|
2021-02-15 08:13:48 -05:00
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-05-28 09:20:54 -04:00
|
|
|
describe('getProjectsDocs', function () {
|
|
|
|
beforeEach(function () {
|
2020-02-16 09:02:55 -05:00
|
|
|
this.filter = { lines: true }
|
|
|
|
this.doc1 = { name: 'mock-doc1' }
|
|
|
|
this.doc2 = { name: 'mock-doc2' }
|
|
|
|
this.doc3 = { name: 'mock-doc3' }
|
|
|
|
this.doc4 = { name: 'mock-doc4' }
|
2020-08-21 12:50:01 -04:00
|
|
|
this.db.docs.find = sinon.stub().returns({
|
2024-01-18 08:00:51 -05:00
|
|
|
toArray: sinon.stub().resolves([this.doc, this.doc3, this.doc4]),
|
2020-08-21 12:50:01 -04:00
|
|
|
})
|
2020-02-16 09:02:55 -05:00
|
|
|
})
|
|
|
|
|
2020-05-28 09:20:54 -04:00
|
|
|
describe('with included_deleted = false', function () {
|
2024-01-18 08:00:51 -05:00
|
|
|
beforeEach(async function () {
|
|
|
|
this.result = await this.MongoManager.promises.getProjectsDocs(
|
2022-04-26 07:16:36 -04:00
|
|
|
this.projectId,
|
2020-02-16 09:02:55 -05:00
|
|
|
{ include_deleted: false },
|
2024-01-18 08:00:51 -05:00
|
|
|
this.filter
|
2020-02-16 09:02:55 -05:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2020-05-28 09:20:54 -04:00
|
|
|
it('should find the non-deleted docs via the project_id', function () {
|
2022-04-19 08:28:47 -04:00
|
|
|
this.db.docs.find
|
2020-02-16 09:02:55 -05:00
|
|
|
.calledWith(
|
|
|
|
{
|
2023-12-13 04:38:54 -05:00
|
|
|
project_id: new ObjectId(this.projectId),
|
2021-07-13 07:04:48 -04:00
|
|
|
deleted: { $ne: true },
|
2020-02-16 09:02:55 -05:00
|
|
|
},
|
2020-09-07 05:16:12 -04:00
|
|
|
{
|
2021-07-13 07:04:48 -04:00
|
|
|
projection: this.filter,
|
2020-09-07 05:16:12 -04:00
|
|
|
}
|
2020-02-16 09:02:55 -05:00
|
|
|
)
|
|
|
|
.should.equal(true)
|
|
|
|
})
|
|
|
|
|
2024-01-18 08:00:51 -05:00
|
|
|
it('should call return the docs', function () {
|
|
|
|
expect(this.result).to.deep.equal([this.doc, this.doc3, this.doc4])
|
2020-02-16 09:02:55 -05:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2022-04-19 08:28:47 -04:00
|
|
|
describe('with included_deleted = true', function () {
|
2024-01-18 08:00:51 -05:00
|
|
|
beforeEach(async function () {
|
|
|
|
this.result = await this.MongoManager.promises.getProjectsDocs(
|
2022-04-26 07:16:36 -04:00
|
|
|
this.projectId,
|
2020-02-16 09:02:55 -05:00
|
|
|
{ include_deleted: true },
|
2024-01-18 08:00:51 -05:00
|
|
|
this.filter
|
2020-02-16 09:02:55 -05:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2020-05-28 09:20:54 -04:00
|
|
|
it('should find all via the project_id', function () {
|
2022-04-19 08:28:47 -04:00
|
|
|
this.db.docs.find
|
2020-02-16 09:02:55 -05:00
|
|
|
.calledWith(
|
|
|
|
{
|
2023-12-13 04:38:54 -05:00
|
|
|
project_id: new ObjectId(this.projectId),
|
2020-02-16 09:02:55 -05:00
|
|
|
},
|
2020-09-07 05:16:12 -04:00
|
|
|
{
|
2021-07-13 07:04:48 -04:00
|
|
|
projection: this.filter,
|
2020-09-07 05:16:12 -04:00
|
|
|
}
|
2020-02-16 09:02:55 -05:00
|
|
|
)
|
|
|
|
.should.equal(true)
|
|
|
|
})
|
|
|
|
|
2024-01-18 08:00:51 -05:00
|
|
|
it('should return the docs', function () {
|
|
|
|
expect(this.result).to.deep.equal([this.doc, this.doc3, this.doc4])
|
2020-02-16 09:02:55 -05:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-02-18 05:10:14 -05:00
|
|
|
describe('getProjectsDeletedDocs', function () {
|
2024-01-18 08:00:51 -05:00
|
|
|
beforeEach(async function () {
|
2021-02-18 05:10:14 -05:00
|
|
|
this.filter = { name: true }
|
|
|
|
this.doc1 = { _id: '1', name: 'mock-doc1.tex' }
|
|
|
|
this.doc2 = { _id: '2', name: 'mock-doc2.tex' }
|
|
|
|
this.doc3 = { _id: '3', name: 'mock-doc3.tex' }
|
|
|
|
this.db.docs.find = sinon.stub().returns({
|
2024-01-18 08:00:51 -05:00
|
|
|
toArray: sinon.stub().resolves([this.doc1, this.doc2, this.doc3]),
|
2021-02-18 05:10:14 -05:00
|
|
|
})
|
2024-01-18 08:00:51 -05:00
|
|
|
this.result = await this.MongoManager.promises.getProjectsDeletedDocs(
|
2022-04-26 07:16:36 -04:00
|
|
|
this.projectId,
|
2024-01-18 08:00:51 -05:00
|
|
|
this.filter
|
2021-02-18 05:10:14 -05:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should find the deleted docs via the project_id', function () {
|
|
|
|
this.db.docs.find
|
|
|
|
.calledWith({
|
2023-12-13 04:38:54 -05:00
|
|
|
project_id: new ObjectId(this.projectId),
|
2021-07-13 07:04:48 -04:00
|
|
|
deleted: true,
|
2021-02-18 05:10:14 -05:00
|
|
|
})
|
|
|
|
.should.equal(true)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should filter, sort by deletedAt and limit', function () {
|
|
|
|
this.db.docs.find
|
|
|
|
.calledWith(sinon.match.any, {
|
|
|
|
projection: this.filter,
|
|
|
|
sort: { deletedAt: -1 },
|
2021-07-13 07:04:48 -04:00
|
|
|
limit: 42,
|
2021-02-18 05:10:14 -05:00
|
|
|
})
|
|
|
|
.should.equal(true)
|
|
|
|
})
|
|
|
|
|
2024-01-18 08:00:51 -05:00
|
|
|
it('should return the docs', function () {
|
|
|
|
expect(this.result).to.deep.equal([this.doc1, this.doc2, this.doc3])
|
2021-02-18 05:10:14 -05:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-05-28 09:20:54 -04:00
|
|
|
describe('upsertIntoDocCollection', function () {
|
|
|
|
beforeEach(function () {
|
2022-04-19 08:28:47 -04:00
|
|
|
this.oldRev = 77
|
2020-02-16 09:02:55 -05:00
|
|
|
})
|
|
|
|
|
2024-01-18 08:00:51 -05:00
|
|
|
it('should upsert the document', async function () {
|
|
|
|
await this.MongoManager.promises.upsertIntoDocCollection(
|
2022-04-26 07:16:36 -04:00
|
|
|
this.projectId,
|
|
|
|
this.docId,
|
2023-03-22 09:08:01 -04:00
|
|
|
this.oldRev,
|
2024-01-18 08:00:51 -05:00
|
|
|
{ lines: this.lines }
|
2020-02-16 09:02:55 -05:00
|
|
|
)
|
|
|
|
|
2024-01-18 08:00:51 -05:00
|
|
|
const args = this.db.docs.updateOne.args[0]
|
|
|
|
assert.deepEqual(args[0], {
|
|
|
|
_id: new ObjectId(this.docId),
|
|
|
|
project_id: new ObjectId(this.projectId),
|
|
|
|
rev: this.oldRev,
|
|
|
|
})
|
|
|
|
assert.equal(args[1].$set.lines, this.lines)
|
|
|
|
assert.equal(args[1].$inc.rev, 1)
|
2020-02-16 09:02:55 -05:00
|
|
|
})
|
2023-03-22 09:08:01 -04:00
|
|
|
|
2024-01-18 08:00:51 -05:00
|
|
|
it('should handle update error', async function () {
|
|
|
|
this.db.docs.updateOne.rejects(this.stubbedErr)
|
|
|
|
await expect(
|
|
|
|
this.MongoManager.promises.upsertIntoDocCollection(
|
|
|
|
this.projectId,
|
|
|
|
this.docId,
|
|
|
|
this.rev,
|
|
|
|
{
|
2023-03-22 09:08:01 -04:00
|
|
|
lines: this.lines,
|
2024-01-18 08:00:51 -05:00
|
|
|
}
|
|
|
|
)
|
|
|
|
).to.be.rejectedWith(this.stubbedErr)
|
2023-03-22 09:08:01 -04:00
|
|
|
})
|
|
|
|
|
2024-01-18 08:00:51 -05:00
|
|
|
it('should insert without a previous rev', async function () {
|
|
|
|
await this.MongoManager.promises.upsertIntoDocCollection(
|
2023-03-22 09:08:01 -04:00
|
|
|
this.projectId,
|
|
|
|
this.docId,
|
|
|
|
null,
|
2024-01-18 08:00:51 -05:00
|
|
|
{ lines: this.lines, ranges: this.ranges }
|
2023-03-22 09:08:01 -04:00
|
|
|
)
|
2024-01-18 08:00:51 -05:00
|
|
|
|
|
|
|
expect(this.db.docs.insertOne).to.have.been.calledWith({
|
|
|
|
_id: new ObjectId(this.docId),
|
|
|
|
project_id: new ObjectId(this.projectId),
|
|
|
|
rev: 1,
|
|
|
|
lines: this.lines,
|
|
|
|
ranges: this.ranges,
|
|
|
|
})
|
2023-03-22 09:08:01 -04:00
|
|
|
})
|
|
|
|
|
2024-01-18 08:00:51 -05:00
|
|
|
it('should handle generic insert error', async function () {
|
|
|
|
this.db.docs.insertOne.rejects(this.stubbedErr)
|
|
|
|
await expect(
|
|
|
|
this.MongoManager.promises.upsertIntoDocCollection(
|
|
|
|
this.projectId,
|
|
|
|
this.docId,
|
|
|
|
null,
|
|
|
|
{ lines: this.lines, ranges: this.ranges }
|
|
|
|
)
|
|
|
|
).to.be.rejectedWith(this.stubbedErr)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should handle duplicate insert error', async function () {
|
|
|
|
this.db.docs.insertOne.rejects({ code: 11000 })
|
|
|
|
await expect(
|
|
|
|
this.MongoManager.promises.upsertIntoDocCollection(
|
|
|
|
this.projectId,
|
|
|
|
this.docId,
|
|
|
|
null,
|
|
|
|
{ lines: this.lines, ranges: this.ranges }
|
|
|
|
)
|
|
|
|
).to.be.rejectedWith(Errors.DocRevValueError)
|
2023-03-22 09:08:01 -04:00
|
|
|
})
|
2020-02-16 09:02:55 -05:00
|
|
|
})
|
|
|
|
|
2022-04-26 07:16:36 -04:00
|
|
|
describe('destroyProject', function () {
|
2024-01-18 08:00:51 -05:00
|
|
|
beforeEach(async function () {
|
2023-12-13 04:38:54 -05:00
|
|
|
this.projectId = new ObjectId()
|
2024-01-18 08:00:51 -05:00
|
|
|
this.db.docs.deleteMany = sinon.stub().resolves()
|
|
|
|
await this.MongoManager.promises.destroyProject(this.projectId)
|
2020-02-16 09:02:55 -05:00
|
|
|
})
|
|
|
|
|
2022-04-26 07:16:36 -04:00
|
|
|
it('should destroy all docs', function () {
|
|
|
|
sinon.assert.calledWith(this.db.docs.deleteMany, {
|
|
|
|
project_id: this.projectId,
|
2020-02-16 09:02:55 -05:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2023-11-08 09:17:19 -05:00
|
|
|
describe('checkRevUnchanged', function () {
|
2021-08-02 06:36:43 -04:00
|
|
|
this.beforeEach(function () {
|
2023-12-13 04:38:54 -05:00
|
|
|
this.doc = { _id: new ObjectId(), name: 'mock-doc', rev: 1 }
|
2021-08-02 06:36:43 -04:00
|
|
|
})
|
|
|
|
|
2024-01-18 08:00:51 -05:00
|
|
|
it('should not error when the rev has not changed', async function () {
|
|
|
|
this.db.docs.findOne = sinon.stub().resolves({ rev: 1 })
|
|
|
|
await this.MongoManager.promises.checkRevUnchanged(this.doc)
|
2021-08-02 06:36:43 -04:00
|
|
|
})
|
|
|
|
|
2024-01-18 08:00:51 -05:00
|
|
|
it('should return an error when the rev has changed', async function () {
|
|
|
|
this.db.docs.findOne = sinon.stub().resolves({ rev: 2 })
|
|
|
|
await expect(
|
|
|
|
this.MongoManager.promises.checkRevUnchanged(this.doc)
|
|
|
|
).to.be.rejectedWith(Errors.DocModifiedError)
|
2021-08-02 06:36:43 -04:00
|
|
|
})
|
2021-11-30 05:27:53 -05:00
|
|
|
|
2024-01-18 08:00:51 -05:00
|
|
|
it('should return a value error if incoming rev is NaN', async function () {
|
|
|
|
this.db.docs.findOne = sinon.stub().resolves({ rev: 2 })
|
2023-12-13 04:38:54 -05:00
|
|
|
this.doc = { _id: new ObjectId(), name: 'mock-doc', rev: NaN }
|
2024-01-18 08:00:51 -05:00
|
|
|
await expect(
|
|
|
|
this.MongoManager.promises.checkRevUnchanged(this.doc)
|
|
|
|
).to.be.rejectedWith(Errors.DocRevValueError)
|
2021-11-30 05:27:53 -05:00
|
|
|
})
|
|
|
|
|
2024-01-18 08:00:51 -05:00
|
|
|
it('should return a value error if checked doc rev is NaN', async function () {
|
|
|
|
this.db.docs.findOne = sinon.stub().resolves({ rev: NaN })
|
|
|
|
await expect(
|
|
|
|
this.MongoManager.promises.checkRevUnchanged(this.doc)
|
|
|
|
).to.be.rejectedWith(Errors.DocRevValueError)
|
2021-11-30 05:27:53 -05:00
|
|
|
})
|
2021-08-02 06:36:43 -04:00
|
|
|
})
|
2022-04-26 07:16:36 -04:00
|
|
|
|
|
|
|
describe('restoreArchivedDoc', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
this.archivedDoc = {
|
|
|
|
lines: ['a', 'b', 'c'],
|
|
|
|
ranges: { some: 'ranges' },
|
|
|
|
rev: 2,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('complete doc', function () {
|
2024-01-18 08:00:51 -05:00
|
|
|
beforeEach(async function () {
|
|
|
|
await this.MongoManager.promises.restoreArchivedDoc(
|
2022-04-26 07:16:36 -04:00
|
|
|
this.projectId,
|
|
|
|
this.docId,
|
2024-01-18 08:00:51 -05:00
|
|
|
this.archivedDoc
|
2022-04-26 07:16:36 -04:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('updates Mongo', function () {
|
|
|
|
expect(this.db.docs.updateOne).to.have.been.calledWith(
|
|
|
|
{
|
2023-12-13 04:38:54 -05:00
|
|
|
_id: new ObjectId(this.docId),
|
|
|
|
project_id: new ObjectId(this.projectId),
|
2022-04-26 07:16:36 -04:00
|
|
|
rev: this.archivedDoc.rev,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
$set: {
|
|
|
|
lines: this.archivedDoc.lines,
|
|
|
|
ranges: this.archivedDoc.ranges,
|
|
|
|
},
|
|
|
|
$unset: {
|
|
|
|
inS3: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('without ranges', function () {
|
2024-01-18 08:00:51 -05:00
|
|
|
beforeEach(async function () {
|
2022-04-26 07:16:36 -04:00
|
|
|
delete this.archivedDoc.ranges
|
2024-01-18 08:00:51 -05:00
|
|
|
await this.MongoManager.promises.restoreArchivedDoc(
|
2022-04-26 07:16:36 -04:00
|
|
|
this.projectId,
|
|
|
|
this.docId,
|
2024-01-18 08:00:51 -05:00
|
|
|
this.archivedDoc
|
2022-04-26 07:16:36 -04:00
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('sets ranges to an empty object', function () {
|
|
|
|
expect(this.db.docs.updateOne).to.have.been.calledWith(
|
|
|
|
{
|
2023-12-13 04:38:54 -05:00
|
|
|
_id: new ObjectId(this.docId),
|
|
|
|
project_id: new ObjectId(this.projectId),
|
2022-04-26 07:16:36 -04:00
|
|
|
rev: this.archivedDoc.rev,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
$set: {
|
|
|
|
lines: this.archivedDoc.lines,
|
|
|
|
ranges: {},
|
|
|
|
},
|
|
|
|
$unset: {
|
|
|
|
inS3: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe("when the update doesn't succeed", function () {
|
2024-01-18 08:00:51 -05:00
|
|
|
it('throws a DocRevValueError', async function () {
|
|
|
|
this.db.docs.updateOne.resolves({ matchedCount: 0 })
|
|
|
|
await expect(
|
|
|
|
this.MongoManager.promises.restoreArchivedDoc(
|
|
|
|
this.projectId,
|
|
|
|
this.docId,
|
|
|
|
this.archivedDoc
|
|
|
|
)
|
|
|
|
).to.be.rejectedWith(Errors.DocRevValueError)
|
2022-04-26 07:16:36 -04:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2020-02-16 09:02:55 -05:00
|
|
|
})
|