Преглед изворни кода

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

Jakob Ackermann пре 6 година
родитељ
комит
1d57706d44

+ 0 - 27
services/document-updater/app/js/mongojs.js

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

Разлика између датотеке није приказан због своје велике величине
+ 71 - 468
services/document-updater/package-lock.json


+ 0 - 1
services/document-updater/package.json

@@ -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",

+ 6 - 7
services/document-updater/test/acceptance/js/RangesTests.js

@@ -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()
-            }
-          )
+            })
         }
       )
     })

+ 6 - 4
services/document-updater/test/acceptance/js/helpers/DocUpdaterApp.js

@@ -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
         })()
       })
-    }
+    })
   }
 }

Неке датотеке нису приказане због велике количине промена