Просмотр исходного кода

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

Jakob Ackermann 6 лет назад
Родитель
Сommit
2fa09928ee

+ 0 - 9
services/docstore/app/js/mongojs.js

@@ -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
-}

Разница между файлами не показана из-за своего большого размера
+ 66 - 484
services/docstore/package-lock.json


+ 0 - 1
services/docstore/package.json

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

+ 9 - 1
services/docstore/test/acceptance/js/ArchiveDocsTests.js

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

+ 15 - 7
services/docstore/test/acceptance/js/DeletingDocsTests.js

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

+ 1 - 1
services/docstore/test/acceptance/js/GettingAllDocsTests.js

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

+ 1 - 1
services/docstore/test/acceptance/js/GettingDocsTests.js

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

+ 1 - 1
services/docstore/test/acceptance/js/UpdatingDocsTests.js

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

Некоторые файлы не были показаны из-за большого количества измененных файлов