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

This commit is contained in:
Jakob Ackermann 2020-08-24 10:01:08 +01:00
parent df0747ec48
commit 2fa09928ee
8 changed files with 135 additions and 678 deletions

View file

@ -1,9 +0,0 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
const Settings = require('settings-sharelatex')
const mongojs = require('mongojs')
const db = mongojs(Settings.mongo.url, ['docs', 'docOps'])
module.exports = {
db,
ObjectId: mongojs.ObjectId
}

File diff suppressed because it is too large Load diff

View file

@ -25,7 +25,6 @@
"express": "^4.17.1",
"logger-sharelatex": "^2.2.0",
"metrics-sharelatex": "^2.7.0",
"mongojs": "3.1.0",
"mongodb": "^3.6.0",
"settings-sharelatex": "^1.1.0",
"streamifier": "^0.1.1",

View file

@ -17,7 +17,7 @@ const Settings = require('settings-sharelatex')
const chai = require('chai')
const { expect } = chai
const should = chai.should()
const { db, ObjectId } = require('../../../app/js/mongojs')
const { getCollection, ObjectId } = require('../../../app/js/mongodb')
const async = require('async')
const DocstoreApp = require('./helpers/DocstoreApp')
const DocstoreClient = require('./helpers/DocstoreClient')
@ -32,6 +32,14 @@ function uploadContent(path, json, callback) {
.catch(callback)
}
let db
before(async function () {
db = {
docs: await getCollection('docs'),
docOps: await getCollection('docOps')
}
})
describe('Archiving', function () {
before(function (done) {
return DocstoreApp.ensureRunning(done)

View file

@ -13,13 +13,21 @@
*/
const chai = require('chai')
chai.should()
const { db, ObjectId } = require('../../../app/js/mongojs')
const { getCollection, ObjectId } = require('../../../app/js/mongodb')
const { expect } = chai
const DocstoreApp = require('./helpers/DocstoreApp')
const Errors = require('../../../app/js/Errors')
const DocstoreClient = require('./helpers/DocstoreClient')
let db
before(async function () {
db = {
docs: await getCollection('docs'),
docOps: await getCollection('docOps')
}
})
describe('Deleting a doc', function () {
beforeEach(function (done) {
this.project_id = ObjectId()
@ -61,7 +69,7 @@ describe('Deleting a doc', function () {
})
return it('should insert a deleted doc into the docs collection', function (done) {
return db.docs.find({ _id: this.doc_id }, (error, docs) => {
return db.docs.find({ _id: this.doc_id }).toArray((error, docs) => {
docs[0]._id.should.deep.equal(this.doc_id)
docs[0].lines.should.deep.equal(this.lines)
docs[0].deleted.should.equal(true)
@ -100,7 +108,7 @@ describe("Destroying a project's documents", function () {
})
it('should remove the doc from the docs collection', function (done) {
return db.docs.find({ _id: this.doc_id }, (err, docs) => {
return db.docs.find({ _id: this.doc_id }).toArray((err, docs) => {
expect(err).not.to.exist
expect(docs).to.deep.equal([])
return done()
@ -108,7 +116,7 @@ describe("Destroying a project's documents", function () {
})
return it('should remove the docOps from the docOps collection', function (done) {
return db.docOps.find({ doc_id: this.doc_id }, (err, docOps) => {
return db.docOps.find({ doc_id: this.doc_id }).toArray((err, docOps) => {
expect(err).not.to.exist
expect(docOps).to.deep.equal([])
return done()
@ -118,7 +126,7 @@ describe("Destroying a project's documents", function () {
return describe('when the doc is archived', function () {
beforeEach(function (done) {
return DocstoreClient.archiveAllDoc(this.project_id, function (err) {
return DocstoreClient.archiveAllDoc(this.project_id, (err) => {
if (err != null) {
return done(err)
}
@ -127,7 +135,7 @@ describe("Destroying a project's documents", function () {
})
it('should remove the doc from the docs collection', function (done) {
return db.docs.find({ _id: this.doc_id }, (err, docs) => {
return db.docs.find({ _id: this.doc_id }).toArray((err, docs) => {
expect(err).not.to.exist
expect(docs).to.deep.equal([])
return done()
@ -135,7 +143,7 @@ describe("Destroying a project's documents", function () {
})
it('should remove the docOps from the docOps collection', function (done) {
return db.docOps.find({ doc_id: this.doc_id }, (err, docOps) => {
return db.docOps.find({ doc_id: this.doc_id }).toArray((err, docOps) => {
expect(err).not.to.exist
expect(docOps).to.deep.equal([])
return done()

View file

@ -14,7 +14,7 @@
const sinon = require('sinon')
const chai = require('chai')
chai.should()
const { ObjectId } = require('mongojs')
const { ObjectId } = require('mongodb')
const async = require('async')
const DocstoreApp = require('./helpers/DocstoreApp')

View file

@ -14,7 +14,7 @@
const sinon = require('sinon')
const chai = require('chai')
chai.should()
const { ObjectId } = require('mongojs')
const { ObjectId } = require('mongodb')
const DocstoreApp = require('./helpers/DocstoreApp')
const DocstoreClient = require('./helpers/DocstoreClient')

View file

@ -13,7 +13,7 @@
const sinon = require('sinon')
const chai = require('chai')
chai.should()
const { ObjectId } = require('mongojs')
const { ObjectId } = require('mongodb')
const DocstoreApp = require('./helpers/DocstoreApp')
const DocstoreClient = require('./helpers/DocstoreClient')