[misc] migrate acceptance tests to the native mongo driver, drop mongojs

This commit is contained in:
Jakob Ackermann 2020-08-25 13:29:58 +01:00
parent f80a92ce46
commit 1d57706d44
5 changed files with 115 additions and 621 deletions

View file

@ -1,27 +0,0 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const Settings = require('settings-sharelatex')
const mongojs = require('mongojs')
const db = mongojs(Settings.mongo.url, ['docSnapshots'])
module.exports = {
db,
ObjectId: mongojs.ObjectId,
healthCheck(callback) {
return db.runCommand({ ping: 1 }, function (err, res) {
if (err != null) {
return callback(err)
}
if (!res.ok) {
return callback(new Error('failed mongo ping'))
}
return callback()
})
}
}

File diff suppressed because it is too large Load diff

View file

@ -26,7 +26,6 @@
"logger-sharelatex": "^2.2.0",
"metrics-sharelatex": "^2.6.2",
"mongodb": "^3.6.0",
"mongojs": "^3.1.0",
"redis-sharelatex": "^1.0.13",
"request": "^2.88.2",
"requestretry": "^4.1.0",

View file

@ -17,7 +17,7 @@ chai.should()
const { expect } = chai
const async = require('async')
const { db, ObjectId } = require('../../../app/js/mongojs')
const { db, ObjectId } = require('../../../app/js/mongodb')
const MockWebApi = require('./helpers/MockWebApi')
const DocUpdaterClient = require('./helpers/DocUpdaterClient')
const DocUpdaterApp = require('./helpers/DocUpdaterApp')
@ -668,12 +668,12 @@ describe('Ranges', function () {
if (error != null) {
return done(error)
}
return db.docSnapshots.find(
{
db.docSnapshots
.find({
project_id: ObjectId(this.project_id),
doc_id: ObjectId(this.doc_id)
},
(error, docSnapshots) => {
})
.toArray((error, docSnapshots) => {
if (error != null) {
return done(error)
}
@ -686,8 +686,7 @@ describe('Ranges', function () {
tid: this.tid
})
return done()
}
)
})
}
)
})

View file

@ -12,6 +12,7 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const app = require('../../../../app')
const { waitForDb } = require('../../../../app/js/mongodb')
require('logger-sharelatex').logger.level('fatal')
module.exports = {
@ -26,9 +27,10 @@ module.exports = {
return callback()
} else if (this.initing) {
return this.callbacks.push(callback)
} else {
this.initing = true
this.callbacks.push(callback)
}
this.initing = true
this.callbacks.push(callback)
waitForDb().then(() => {
return app.listen(3003, 'localhost', (error) => {
if (error != null) {
throw error
@ -42,6 +44,6 @@ module.exports = {
return result
})()
})
}
})
}
}