Merge branches 'jpa-bump-bson', 'jpa-mongo-find-query-cleanup', 'jpa-mongo-js-cleanup' and 'jpa-mongo-update-query-cleanup' into jpa-mongodb-native
This commit is contained in:
@@ -190,7 +190,7 @@ describe('MongoManager', function () {
|
||||
beforeEach(function () {
|
||||
this.metadata = { mock: 'metadata' }
|
||||
this.db.projectHistoryMetaData = {
|
||||
find: sinon.stub().callsArgWith(1, null, [this.metadata])
|
||||
findOne: sinon.stub().callsArgWith(1, null, this.metadata)
|
||||
}
|
||||
return this.MongoManager.getProjectMetaData(
|
||||
this.project_id,
|
||||
@@ -199,7 +199,7 @@ describe('MongoManager', function () {
|
||||
})
|
||||
|
||||
it('should look up the meta data in the db', function () {
|
||||
return this.db.projectHistoryMetaData.find
|
||||
return this.db.projectHistoryMetaData.findOne
|
||||
.calledWith({ project_id: ObjectId(this.project_id) })
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
@@ -67,6 +67,7 @@ describe('PackManager', function () {
|
||||
return (this.db.docHistory = {
|
||||
save: sinon.stub().callsArg(1),
|
||||
insert: sinon.stub().callsArg(1),
|
||||
updateOne: sinon.stub().yields(),
|
||||
findAndModify: sinon.stub().callsArg(1)
|
||||
})
|
||||
})
|
||||
@@ -442,23 +443,21 @@ describe('PackManager', function () {
|
||||
|
||||
return describe('for a small update that will expire', function () {
|
||||
it('should append the update in mongo', function () {
|
||||
return this.db.docHistory.findAndModify
|
||||
.calledWithMatch({
|
||||
query: { _id: this.lastUpdate._id },
|
||||
update: {
|
||||
return this.db.docHistory.updateOne
|
||||
.calledWithMatch(
|
||||
{ _id: this.lastUpdate._id },
|
||||
{
|
||||
$push: { pack: { $each: this.newUpdates } },
|
||||
$set: { v_end: this.newUpdates[this.newUpdates.length - 1].v }
|
||||
}
|
||||
})
|
||||
)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should set an expiry time in the future', function () {
|
||||
return this.db.docHistory.findAndModify
|
||||
.calledWithMatch({
|
||||
update: {
|
||||
$set: { expiresAt: new Date(Date.now() + 7 * 24 * 3600 * 1000) }
|
||||
}
|
||||
return this.db.docHistory.updateOne
|
||||
.calledWithMatch(sinon.match.any, {
|
||||
$set: { expiresAt: new Date(Date.now() + 7 * 24 * 3600 * 1000) }
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user