diff --git a/services/document-updater/test/unit/coffee/DocumentManager/flushAndDeleteDocTests.coffee b/services/document-updater/test/unit/coffee/DocumentManager/flushAndDeleteDocTests.coffee index 3b9a4314a4..911efce1ba 100644 --- a/services/document-updater/test/unit/coffee/DocumentManager/flushAndDeleteDocTests.coffee +++ b/services/document-updater/test/unit/coffee/DocumentManager/flushAndDeleteDocTests.coffee @@ -4,7 +4,7 @@ should = chai.should() modulePath = "../../../../app/js/DocumentManager.js" SandboxedModule = require('sandboxed-module') -describe "DocumentUpdater - flushAndDeleteDoc", -> +describe "DocumentUpdater.flushAndDeleteDoc", -> beforeEach -> @DocumentManager = SandboxedModule.require modulePath, requires: "./RedisManager": @RedisManager = {} diff --git a/services/document-updater/test/unit/coffee/DocumentManager/flushDocTests.coffee b/services/document-updater/test/unit/coffee/DocumentManager/flushDocIfLoadedTests.coffee similarity index 96% rename from services/document-updater/test/unit/coffee/DocumentManager/flushDocTests.coffee rename to services/document-updater/test/unit/coffee/DocumentManager/flushDocIfLoadedTests.coffee index 6bdba1a2b7..bda914999b 100644 --- a/services/document-updater/test/unit/coffee/DocumentManager/flushDocTests.coffee +++ b/services/document-updater/test/unit/coffee/DocumentManager/flushDocIfLoadedTests.coffee @@ -4,7 +4,7 @@ should = chai.should() modulePath = "../../../../app/js/DocumentManager.js" SandboxedModule = require('sandboxed-module') -describe "DocumentUpdater - flushDocIfLoaded", -> +describe "DocumentManager.flushDocIfLoaded", -> beforeEach -> @DocumentManager = SandboxedModule.require modulePath, requires: "./RedisManager": @RedisManager = {} @@ -14,6 +14,7 @@ describe "DocumentUpdater - flushDocIfLoaded", -> "./Metrics": @Metrics = Timer: class Timer done: sinon.stub() + "./TrackChangesManager": {} @project_id = "project-id-123" @doc_id = "doc-id-123" @lines = ["one", "two", "three"] diff --git a/services/document-updater/test/unit/coffee/DocumentManager/getDocAndRecentOpsTests.coffee b/services/document-updater/test/unit/coffee/DocumentManager/getDocAndRecentOpsTests.coffee index 7a296cc47d..8c54b2b854 100644 --- a/services/document-updater/test/unit/coffee/DocumentManager/getDocAndRecentOpsTests.coffee +++ b/services/document-updater/test/unit/coffee/DocumentManager/getDocAndRecentOpsTests.coffee @@ -4,7 +4,7 @@ should = chai.should() modulePath = "../../../../app/js/DocumentManager.js" SandboxedModule = require('sandboxed-module') -describe "DocumentUpdater - getDocAndRecentOps", -> +describe "DocumentUpdater.getDocAndRecentOps", -> beforeEach -> @DocumentManager = SandboxedModule.require modulePath, requires: "./RedisManager": @RedisManager = {} @@ -14,6 +14,7 @@ describe "DocumentUpdater - getDocAndRecentOps", -> "./Metrics": @Metrics = Timer: class Timer done: sinon.stub() + "./TrackChangesManager": {} @project_id = "project-id-123" @doc_id = "doc-id-123" diff --git a/services/document-updater/test/unit/coffee/DocumentManager/getDocTests.coffee b/services/document-updater/test/unit/coffee/DocumentManager/getDocTests.coffee index 0db51ddba8..b11686ac3c 100644 --- a/services/document-updater/test/unit/coffee/DocumentManager/getDocTests.coffee +++ b/services/document-updater/test/unit/coffee/DocumentManager/getDocTests.coffee @@ -4,7 +4,7 @@ should = chai.should() modulePath = "../../../../app/js/DocumentManager.js" SandboxedModule = require('sandboxed-module') -describe "DocumentUpdater - getDoc", -> +describe "DocumentUpdater.getDoc", -> beforeEach -> @DocumentManager = SandboxedModule.require modulePath, requires: "./RedisManager": @RedisManager = {} @@ -14,6 +14,7 @@ describe "DocumentUpdater - getDoc", -> "./Metrics": @Metrics = Timer: class Timer done: sinon.stub() + "./TrackChangesManager": {} @project_id = "project-id-123" @doc_id = "doc-id-123" diff --git a/services/document-updater/test/unit/coffee/DocumentManager/setDocTests.coffee b/services/document-updater/test/unit/coffee/DocumentManager/setDocTests.coffee index 76067f943e..9307c42feb 100644 --- a/services/document-updater/test/unit/coffee/DocumentManager/setDocTests.coffee +++ b/services/document-updater/test/unit/coffee/DocumentManager/setDocTests.coffee @@ -4,7 +4,7 @@ should = chai.should() modulePath = "../../../../app/js/DocumentManager.js" SandboxedModule = require('sandboxed-module') -describe "DocumentManager - setDoc", -> +describe "DocumentManager.setDoc", -> beforeEach -> @DocumentManager = SandboxedModule.require modulePath, requires: "./RedisManager": @RedisManager = {} @@ -16,6 +16,7 @@ describe "DocumentManager - setDoc", -> "./Metrics": @Metrics = Timer: class Timer done: sinon.stub() + "./TrackChangesManager": {} @project_id = "project-id-123" @doc_id = "doc-id-123" diff --git a/services/document-updater/test/unit/coffee/GettingListOfPendingUpdates.coffee b/services/document-updater/test/unit/coffee/GettingListOfPendingUpdates.coffee deleted file mode 100644 index 10d1c39038..0000000000 --- a/services/document-updater/test/unit/coffee/GettingListOfPendingUpdates.coffee +++ /dev/null @@ -1,42 +0,0 @@ -assert = require('assert') -should = require('chai').should() -path = require('path') -modulePath = path.join __dirname, '../../../app/js/RedisManager.js' -_ = require('underscore') -SandboxedModule = require('sandboxed-module') -keys = require(path.join __dirname, '../../../app/js/RedisKeyBuilder.js') - -describe 'getting entire list of pending updates', ()-> - - doc_id = 123 - redisMemory = {} - correctUpdates = [{"update1"}, {"update2"}, {"update3"}] - jsonCorrectUpdates = _.map correctUpdates, (d)-> JSON.stringify d - redisMemory[keys.pendingUpdates(doc_id:doc_id)] = jsonCorrectUpdates - redisMemory[keys.pendingUpdates(doc_id:"notThis")] = JSON.stringify([{"updatex"}, {"updatez"}]) - - redisReturn = [] - - mocks = - "redis-sharelatex": - createClient: ()-> - auth:-> - multi: ()-> - lrange:(key, start, end)-> - key.should.equal(keys.pendingUpdates(doc_id:doc_id)) - start.should.equal(0) - end.should.equal(-1) - redisReturn.push(redisMemory[key]) - del : (key)-> - key.should.equal(keys.pendingUpdates(doc_id:doc_id)) - redisReturn.push(1) - exec: (callback)-> - callback(null, redisReturn) - - redisManager = SandboxedModule.require(modulePath, requires: mocks) - - it 'should have 3 elements in array', (done)-> - redisManager.getPendingUpdatesForDoc doc_id, (err, listOfUpdates)-> - listOfUpdates.length.should.equal(3) - done() - diff --git a/services/document-updater/test/unit/coffee/HttpController/deleteProjectTests.coffee b/services/document-updater/test/unit/coffee/HttpController/deleteProjectTests.coffee index e3c6eda35c..796df52e80 100644 --- a/services/document-updater/test/unit/coffee/HttpController/deleteProjectTests.coffee +++ b/services/document-updater/test/unit/coffee/HttpController/deleteProjectTests.coffee @@ -5,7 +5,7 @@ modulePath = "../../../../app/js/HttpController.js" SandboxedModule = require('sandboxed-module') Errors = require "../../../../app/js/Errors.js" -describe "HttpController - deleteProject", -> +describe "HttpController.deleteProject", -> beforeEach -> @HttpController = SandboxedModule.require modulePath, requires: "./DocumentManager": @DocumentManager = {} diff --git a/services/document-updater/test/unit/coffee/HttpController/flushAndDeleteDocTests.coffee b/services/document-updater/test/unit/coffee/HttpController/flushAndDeleteDocTests.coffee index f586b6c4f8..af09c2c1bd 100644 --- a/services/document-updater/test/unit/coffee/HttpController/flushAndDeleteDocTests.coffee +++ b/services/document-updater/test/unit/coffee/HttpController/flushAndDeleteDocTests.coffee @@ -5,7 +5,7 @@ modulePath = "../../../../app/js/HttpController.js" SandboxedModule = require('sandboxed-module') Errors = require "../../../../app/js/Errors.js" -describe "HttpController - flushAndDeleteDoc", -> +describe "HttpController.flushAndDeleteDoc", -> beforeEach -> @HttpController = SandboxedModule.require modulePath, requires: "./DocumentManager": @DocumentManager = {} diff --git a/services/document-updater/test/unit/coffee/HttpController/flushDocIfLoadedTests.coffee b/services/document-updater/test/unit/coffee/HttpController/flushDocIfLoadedTests.coffee index 69c0137676..3321030624 100644 --- a/services/document-updater/test/unit/coffee/HttpController/flushDocIfLoadedTests.coffee +++ b/services/document-updater/test/unit/coffee/HttpController/flushDocIfLoadedTests.coffee @@ -5,7 +5,7 @@ modulePath = "../../../../app/js/HttpController.js" SandboxedModule = require('sandboxed-module') Errors = require "../../../../app/js/Errors.js" -describe "HttpController - flushDocIfLoaded", -> +describe "HttpController.flushDocIfLoaded", -> beforeEach -> @HttpController = SandboxedModule.require modulePath, requires: "./DocumentManager": @DocumentManager = {} diff --git a/services/document-updater/test/unit/coffee/HttpController/flushProjectTests.coffee b/services/document-updater/test/unit/coffee/HttpController/flushProjectTests.coffee index 5175cd4280..e45269ce6d 100644 --- a/services/document-updater/test/unit/coffee/HttpController/flushProjectTests.coffee +++ b/services/document-updater/test/unit/coffee/HttpController/flushProjectTests.coffee @@ -5,7 +5,7 @@ modulePath = "../../../../app/js/HttpController.js" SandboxedModule = require('sandboxed-module') Errors = require "../../../../app/js/Errors.js" -describe "HttpController - flushProject", -> +describe "HttpController.flushProject", -> beforeEach -> @HttpController = SandboxedModule.require modulePath, requires: "./DocumentManager": @DocumentManager = {} diff --git a/services/document-updater/test/unit/coffee/HttpController/getDocTests.coffee b/services/document-updater/test/unit/coffee/HttpController/getDocTests.coffee index 4ec493bc4b..17e5ad8e08 100644 --- a/services/document-updater/test/unit/coffee/HttpController/getDocTests.coffee +++ b/services/document-updater/test/unit/coffee/HttpController/getDocTests.coffee @@ -5,7 +5,7 @@ modulePath = "../../../../app/js/HttpController.js" SandboxedModule = require('sandboxed-module') Errors = require "../../../../app/js/Errors.js" -describe "HttpController - getDoc", -> +describe "HttpController.getDoc", -> beforeEach -> @HttpController = SandboxedModule.require modulePath, requires: "./DocumentManager": @DocumentManager = {} diff --git a/services/document-updater/test/unit/coffee/HttpController/setDocTests.coffee b/services/document-updater/test/unit/coffee/HttpController/setDocTests.coffee index dd2a7c1d59..b60549c137 100644 --- a/services/document-updater/test/unit/coffee/HttpController/setDocTests.coffee +++ b/services/document-updater/test/unit/coffee/HttpController/setDocTests.coffee @@ -5,7 +5,7 @@ modulePath = "../../../../app/js/HttpController.js" SandboxedModule = require('sandboxed-module') Errors = require "../../../../app/js/Errors.js" -describe "HttpController - setDoc", -> +describe "HttpController.setDoc", -> beforeEach -> @HttpController = SandboxedModule.require modulePath, requires: "./DocumentManager": @DocumentManager = {} diff --git a/services/document-updater/test/unit/coffee/LockManager/CheckingTheLock.coffee b/services/document-updater/test/unit/coffee/LockManager/CheckingTheLock.coffee index 598c4903c2..84c34f0725 100644 --- a/services/document-updater/test/unit/coffee/LockManager/CheckingTheLock.coffee +++ b/services/document-updater/test/unit/coffee/LockManager/CheckingTheLock.coffee @@ -27,6 +27,7 @@ describe 'Lock Manager - checking the lock', ()-> expire: exireStub set: setStub exec: execStub + "./Metrics": {inc: () ->} LockManager = SandboxedModule.require(modulePath, requires: mocks) it 'should check if lock exists but not set or expire', (done)-> diff --git a/services/document-updater/test/unit/coffee/LockManager/ReleasingTheLock.coffee b/services/document-updater/test/unit/coffee/LockManager/ReleasingTheLock.coffee index 4ae75e7719..3b8b09877d 100644 --- a/services/document-updater/test/unit/coffee/LockManager/ReleasingTheLock.coffee +++ b/services/document-updater/test/unit/coffee/LockManager/ReleasingTheLock.coffee @@ -18,6 +18,7 @@ describe 'LockManager - releasing the lock', ()-> createClient : ()-> auth:-> del:deleteStub + "./Metrics": {inc: () ->} LockManager = SandboxedModule.require(modulePath, requires: mocks) diff --git a/services/document-updater/test/unit/coffee/LockManager/getLockTests.coffee b/services/document-updater/test/unit/coffee/LockManager/getLockTests.coffee index 3147f9701a..026bd81538 100644 --- a/services/document-updater/test/unit/coffee/LockManager/getLockTests.coffee +++ b/services/document-updater/test/unit/coffee/LockManager/getLockTests.coffee @@ -11,6 +11,7 @@ describe 'LockManager - getting the lock', -> "redis-sharelatex": createClient : () => auth:-> + "./Metrics": {inc: () ->} @callback = sinon.stub() @doc_id = "doc-id-123" diff --git a/services/document-updater/test/unit/coffee/LockManager/tryLockTests.coffee b/services/document-updater/test/unit/coffee/LockManager/tryLockTests.coffee index c828399c12..0a1ddc00e9 100644 --- a/services/document-updater/test/unit/coffee/LockManager/tryLockTests.coffee +++ b/services/document-updater/test/unit/coffee/LockManager/tryLockTests.coffee @@ -12,6 +12,8 @@ describe 'LockManager - trying the lock', -> createClient : () => auth:-> set: @set = sinon.stub() + "./Metrics": {inc: () ->} + @callback = sinon.stub() @doc_id = "doc-id-123" diff --git a/services/document-updater/test/unit/coffee/PersistenceManager/getDocFromWebTests.coffee b/services/document-updater/test/unit/coffee/PersistenceManager/getDocFromWebTests.coffee index 82ee937591..2207ea1e7d 100644 --- a/services/document-updater/test/unit/coffee/PersistenceManager/getDocFromWebTests.coffee +++ b/services/document-updater/test/unit/coffee/PersistenceManager/getDocFromWebTests.coffee @@ -13,6 +13,7 @@ describe "PersistenceManager.getDocFromWeb", -> "./Metrics": @Metrics = Timer: class Timer done: sinon.stub() + "logger-sharelatex": @logger = {log: sinon.stub(), err: sinon.stub()} @project_id = "project-id-123" @doc_id = "doc-id-123" @lines = ["one", "two", "three"] diff --git a/services/document-updater/test/unit/coffee/PersistenceManager/getDocVersionInMongoTests.coffee b/services/document-updater/test/unit/coffee/PersistenceManager/getDocVersionInMongoTests.coffee index a5015279fe..2ab89f6795 100644 --- a/services/document-updater/test/unit/coffee/PersistenceManager/getDocVersionInMongoTests.coffee +++ b/services/document-updater/test/unit/coffee/PersistenceManager/getDocVersionInMongoTests.coffee @@ -17,6 +17,7 @@ describe "PersistenceManager.getDocVersionInMongo", -> "./mongojs": db: @db = { docOps: {} } ObjectId: ObjectId + "logger-sharelatex": @logger = {log: sinon.stub(), err: sinon.stub()} @doc_id = ObjectId().toString() @callback = sinon.stub() diff --git a/services/document-updater/test/unit/coffee/PersistenceManager/setDocInWebTests.coffee b/services/document-updater/test/unit/coffee/PersistenceManager/setDocInWebTests.coffee index ad218caa10..d7e6727e9a 100644 --- a/services/document-updater/test/unit/coffee/PersistenceManager/setDocInWebTests.coffee +++ b/services/document-updater/test/unit/coffee/PersistenceManager/setDocInWebTests.coffee @@ -13,6 +13,7 @@ describe "PersistenceManager.setDocInWeb", -> "./Metrics": @Metrics = Timer: class Timer done: sinon.stub() + "logger-sharelatex": @logger = {log: sinon.stub(), err: sinon.stub()} @project_id = "project-id-123" @doc_id = "doc-id-123" @lines = ["one", "two", "three"] diff --git a/services/document-updater/test/unit/coffee/PersistenceManager/setDocVersionInMongo.coffee b/services/document-updater/test/unit/coffee/PersistenceManager/setDocVersionInMongo.coffee index 7f228fc341..d642aba0d8 100644 --- a/services/document-updater/test/unit/coffee/PersistenceManager/setDocVersionInMongo.coffee +++ b/services/document-updater/test/unit/coffee/PersistenceManager/setDocVersionInMongo.coffee @@ -17,6 +17,7 @@ describe "PersistenceManager.getDocVersionInMongo", -> "./mongojs": db: @db = { docOps: {} } ObjectId: ObjectId + "logger-sharelatex": @logger = {log: sinon.stub(), err: sinon.stub()} @doc_id = ObjectId().toString() @callback = sinon.stub() diff --git a/services/document-updater/test/unit/coffee/RedisManager/clearDocFromPendingUpdatesSetTests.coffee b/services/document-updater/test/unit/coffee/RedisManager/clearDocFromPendingUpdatesSetTests.coffee index 86ab837a2f..c89842f7bc 100644 --- a/services/document-updater/test/unit/coffee/RedisManager/clearDocFromPendingUpdatesSetTests.coffee +++ b/services/document-updater/test/unit/coffee/RedisManager/clearDocFromPendingUpdatesSetTests.coffee @@ -13,6 +13,7 @@ describe "RedisManager.clearDocFromPendingUpdatesSet", -> "redis-sharelatex" : createClient: () => @rclient ?= auth:-> # only assign one rclient "logger-sharelatex": {} + "./ZipManager": {} @rclient.srem = sinon.stub().callsArg(2) @RedisManager.clearDocFromPendingUpdatesSet(@project_id, @doc_id, @callback) diff --git a/services/document-updater/test/unit/coffee/GettingTotalNumberOfDocs.coffee b/services/document-updater/test/unit/coffee/RedisManager/getCountOfDocsInMemoryTests.coffee similarity index 83% rename from services/document-updater/test/unit/coffee/GettingTotalNumberOfDocs.coffee rename to services/document-updater/test/unit/coffee/RedisManager/getCountOfDocsInMemoryTests.coffee index bac04361c3..e66fecf86a 100644 --- a/services/document-updater/test/unit/coffee/GettingTotalNumberOfDocs.coffee +++ b/services/document-updater/test/unit/coffee/RedisManager/getCountOfDocsInMemoryTests.coffee @@ -2,11 +2,11 @@ require('coffee-script') assert = require('assert') should = require('chai').should() path = require('path') -modulePath = path.join __dirname, '../../../app/js/RedisManager.js' -keys = require(path.join __dirname, '../../../app/js/RedisKeyBuilder.js') +modulePath = path.join __dirname, '../../../../app/js/RedisManager.js' +keys = require(path.join __dirname, '../../../../app/js/RedisKeyBuilder.js') SandboxedModule = require('sandboxed-module') -describe 'getting cound of docs from memory', ()-> +describe 'RedisManager.getCountOfDocsInMemory', ()-> project_id = "12345" doc_id1 = "docid1" @@ -18,6 +18,7 @@ describe 'getting cound of docs from memory', ()-> beforeEach (done)-> mocks = + "./ZipManager": {} "logger-sharelatex": log:-> "redis-sharelatex": createClient : ()-> diff --git a/services/document-updater/test/unit/coffee/GettingDoc.coffee b/services/document-updater/test/unit/coffee/RedisManager/getDocTests.coffee similarity index 92% rename from services/document-updater/test/unit/coffee/GettingDoc.coffee rename to services/document-updater/test/unit/coffee/RedisManager/getDocTests.coffee index 0b4b466c24..e16ff856dd 100644 --- a/services/document-updater/test/unit/coffee/GettingDoc.coffee +++ b/services/document-updater/test/unit/coffee/RedisManager/getDocTests.coffee @@ -1,7 +1,7 @@ sinon = require('sinon') chai = require('chai') should = chai.should() -modulePath = "../../../app/js/RedisManager.js" +modulePath = "../../../../app/js/RedisManager.js" SandboxedModule = require('sandboxed-module') describe 'RedisManager.getDoc', -> @@ -11,6 +11,7 @@ describe 'RedisManager.getDoc', -> @rclient.multi = () => @rclient @RedisManager = SandboxedModule.require modulePath, requires: + "logger-sharelatex": {} "redis-sharelatex": @redis = createClient: () => @rclient diff --git a/services/document-updater/test/unit/coffee/RedisManager/getDocsWithPendingUpdatesTests.coffee b/services/document-updater/test/unit/coffee/RedisManager/getDocsWithPendingUpdatesTests.coffee index 2f54ba171e..45efa4c984 100644 --- a/services/document-updater/test/unit/coffee/RedisManager/getDocsWithPendingUpdatesTests.coffee +++ b/services/document-updater/test/unit/coffee/RedisManager/getDocsWithPendingUpdatesTests.coffee @@ -8,6 +8,7 @@ describe "RedisManager.getDocsWithPendingUpdates", -> beforeEach -> @callback = sinon.stub() @RedisManager = SandboxedModule.require modulePath, requires: + "./ZipManager": {} "redis-sharelatex" : createClient: () => @rclient ?= auth:-> "logger-sharelatex": {} diff --git a/services/document-updater/test/unit/coffee/RedisManager/getPendingUpdatesForDocTests.coffee b/services/document-updater/test/unit/coffee/RedisManager/getPendingUpdatesForDocTests.coffee index 9c70033eb4..40efa7cec2 100644 --- a/services/document-updater/test/unit/coffee/RedisManager/getPendingUpdatesForDocTests.coffee +++ b/services/document-updater/test/unit/coffee/RedisManager/getPendingUpdatesForDocTests.coffee @@ -7,6 +7,7 @@ SandboxedModule = require('sandboxed-module') describe "RedisManager.getPendingUpdatesForDoc", -> beforeEach -> @RedisManager = SandboxedModule.require modulePath, requires: + "./ZipManager": {} "redis-sharelatex": createClient: () => @rclient = auth: () -> diff --git a/services/document-updater/test/unit/coffee/RedisManager/getPreviousDocOpsTests.coffee b/services/document-updater/test/unit/coffee/RedisManager/getPreviousDocOpsTests.coffee index 4a6d42c1ab..eb17d7856f 100644 --- a/services/document-updater/test/unit/coffee/RedisManager/getPreviousDocOpsTests.coffee +++ b/services/document-updater/test/unit/coffee/RedisManager/getPreviousDocOpsTests.coffee @@ -8,6 +8,7 @@ describe "RedisManager.getPreviousDocOpsTests", -> beforeEach -> @callback = sinon.stub() @RedisManager = SandboxedModule.require modulePath, requires: + "./ZipManager": {} "redis-sharelatex" : createClient: () => @rclient ?= auth: -> diff --git a/services/document-updater/test/unit/coffee/CheckingUpdatesLength.coffee b/services/document-updater/test/unit/coffee/RedisManager/getUpdatesLengthTests.coffee similarity index 80% rename from services/document-updater/test/unit/coffee/CheckingUpdatesLength.coffee rename to services/document-updater/test/unit/coffee/RedisManager/getUpdatesLengthTests.coffee index de04724fef..57e7cb1e02 100644 --- a/services/document-updater/test/unit/coffee/CheckingUpdatesLength.coffee +++ b/services/document-updater/test/unit/coffee/RedisManager/getUpdatesLengthTests.coffee @@ -2,17 +2,19 @@ assert = require('chai').assert sinon = require('sinon') chai = require('chai') should = chai.should() -modulePath = "../../../app/js/RedisManager.js" +modulePath = "../../../../app/js/RedisManager.js" SandboxedModule = require('sandboxed-module') doc_id = "1234" -describe 'Document Manager - getUpdatesLength ', -> +describe 'Redis Manager.getUpdatesLength ', -> beforeEach -> @llenStub = sinon.stub() @redisManager = SandboxedModule.require modulePath, requires: + "./ZipManager": {} + "logger-sharelatex": {} "redis-sharelatex": createClient:=> auth:-> diff --git a/services/document-updater/test/unit/coffee/RedisManager/pushDocOpTests.coffee b/services/document-updater/test/unit/coffee/RedisManager/pushDocOpTests.coffee index a90b20bced..1053ed75c1 100644 --- a/services/document-updater/test/unit/coffee/RedisManager/pushDocOpTests.coffee +++ b/services/document-updater/test/unit/coffee/RedisManager/pushDocOpTests.coffee @@ -7,6 +7,7 @@ SandboxedModule = require('sandboxed-module') describe "RedisManager.pushDocOp", -> beforeEach -> @RedisManager = SandboxedModule.require modulePath, requires: + "./ZipManager": {} "redis-sharelatex": createClient: () => @rclient ?= auth: () -> diff --git a/services/document-updater/test/unit/coffee/RedisManager/pushUncompressedHistoryOpTests.coffee b/services/document-updater/test/unit/coffee/RedisManager/pushUncompressedHistoryOpTests.coffee index 82b28a25d2..c7423fcff0 100644 --- a/services/document-updater/test/unit/coffee/RedisManager/pushUncompressedHistoryOpTests.coffee +++ b/services/document-updater/test/unit/coffee/RedisManager/pushUncompressedHistoryOpTests.coffee @@ -7,6 +7,7 @@ SandboxedModule = require('sandboxed-module') describe "RedisManager.pushUncompressedHistoryOp", -> beforeEach -> @RedisManager = SandboxedModule.require modulePath, requires: + "./ZipManager": {} "redis-sharelatex": createClient: () => @rclient ?= auth: () -> diff --git a/services/document-updater/test/unit/coffee/AddingDocsToMemory.coffee b/services/document-updater/test/unit/coffee/RedisManager/putDocInMemoryTests.coffee similarity index 87% rename from services/document-updater/test/unit/coffee/AddingDocsToMemory.coffee rename to services/document-updater/test/unit/coffee/RedisManager/putDocInMemoryTests.coffee index 328eb13b8c..16043e7e2c 100644 --- a/services/document-updater/test/unit/coffee/AddingDocsToMemory.coffee +++ b/services/document-updater/test/unit/coffee/RedisManager/putDocInMemoryTests.coffee @@ -1,13 +1,13 @@ require('coffee-script') assert = require('assert') path = require('path') -modulePath = path.join __dirname, '../../../app/js/RedisManager.js' -keys = require(path.join __dirname, '../../../app/js/RedisKeyBuilder.js') +modulePath = path.join __dirname, '../../../../app/js/RedisManager.js' +keys = require(path.join __dirname, '../../../../app/js/RedisKeyBuilder.js') project_id = 1234 doc_id = 5678 SandboxedModule = require('sandboxed-module') -describe 'putting a doc into memory', ()-> +describe 'RedisManager.putDocInMemory', ()-> lines = ["this is one line", "and another line"] version = 42 @@ -21,6 +21,7 @@ describe 'putting a doc into memory', ()-> potentialSAdds[keys.docsInProject(project_id:project_id)] = doc_id mocks = + "./ZipManager": {} "logger-sharelatex": log:-> "redis-sharelatex": createClient : ()-> diff --git a/services/document-updater/test/unit/coffee/RemovingSingleDocFromMemory.coffee b/services/document-updater/test/unit/coffee/RedisManager/removeDocFromMemoryTests.coffee similarity index 89% rename from services/document-updater/test/unit/coffee/RemovingSingleDocFromMemory.coffee rename to services/document-updater/test/unit/coffee/RedisManager/removeDocFromMemoryTests.coffee index aad1e94804..2c5076bb1c 100644 --- a/services/document-updater/test/unit/coffee/RemovingSingleDocFromMemory.coffee +++ b/services/document-updater/test/unit/coffee/RedisManager/removeDocFromMemoryTests.coffee @@ -3,11 +3,11 @@ _ = require("underscore") assert = require('assert') sinon = require('sinon') path = require('path') -modulePath = path.join __dirname, '../../../app/js/RedisManager.js' -keys = require(path.join __dirname, '../../../app/js/RedisKeyBuilder.js') +modulePath = path.join __dirname, '../../../../app/js/RedisManager.js' +keys = require(path.join __dirname, '../../../../app/js/RedisKeyBuilder.js') SandboxedModule = require('sandboxed-module') -describe 'removing single doc from memory', ()-> +describe 'RedisManager.removeDocFromMemory', ()-> project_id = "12345" doc_id1 = "docid1" @@ -21,6 +21,7 @@ describe 'removing single doc from memory', ()-> redisMemory = {} mocks = + "./ZipManager": {} "logger-sharelatex": error:-> log:-> diff --git a/services/document-updater/test/unit/coffee/ShareJsDB/GetOpsTests.coffee b/services/document-updater/test/unit/coffee/ShareJsDB/GetOpsTests.coffee index 4812619574..31830e5afc 100644 --- a/services/document-updater/test/unit/coffee/ShareJsDB/GetOpsTests.coffee +++ b/services/document-updater/test/unit/coffee/ShareJsDB/GetOpsTests.coffee @@ -16,6 +16,7 @@ describe "ShareJsDB.getOps", -> "./RedisManager": @RedisManager = {} "./DocOpsManager": @DocOpsManager = {} "./DocumentManager":{} + "logger-sharelatex": {} describe "with start == end", -> beforeEach -> diff --git a/services/document-updater/test/unit/coffee/ShareJsDB/GetSnapshotTests.coffee b/services/document-updater/test/unit/coffee/ShareJsDB/GetSnapshotTests.coffee index ef433c1f90..1cd1e62c4e 100644 --- a/services/document-updater/test/unit/coffee/ShareJsDB/GetSnapshotTests.coffee +++ b/services/document-updater/test/unit/coffee/ShareJsDB/GetSnapshotTests.coffee @@ -16,6 +16,7 @@ describe "ShareJsDB.getSnapshot", -> "./DocumentManager": @DocumentManager = {} "./RedisManager": {} "./DocOpsManager": {} + "logger-sharelatex": {} @version = 42 diff --git a/services/document-updater/test/unit/coffee/ShareJsDB/WriteOpsTests.coffee b/services/document-updater/test/unit/coffee/ShareJsDB/WriteOpsTests.coffee index 6088de77f4..30e92bad3c 100644 --- a/services/document-updater/test/unit/coffee/ShareJsDB/WriteOpsTests.coffee +++ b/services/document-updater/test/unit/coffee/ShareJsDB/WriteOpsTests.coffee @@ -17,6 +17,7 @@ describe "ShareJsDB.writeOps", -> "./RedisManager": @RedisManager = {} "./DocOpsManager": @DocOpsManager = {} "./DocumentManager": {} + "logger-sharelatex": @logger = {error: sinon.stub()} describe "writing an op", -> beforeEach -> diff --git a/services/document-updater/test/unit/coffee/ShareJsUpdateManagerTests.coffee b/services/document-updater/test/unit/coffee/ShareJsUpdateManager/ShareJsUpdateManagerTests.coffee similarity index 98% rename from services/document-updater/test/unit/coffee/ShareJsUpdateManagerTests.coffee rename to services/document-updater/test/unit/coffee/ShareJsUpdateManager/ShareJsUpdateManagerTests.coffee index ecccc91a7e..6d21ca3889 100644 --- a/services/document-updater/test/unit/coffee/ShareJsUpdateManagerTests.coffee +++ b/services/document-updater/test/unit/coffee/ShareJsUpdateManager/ShareJsUpdateManagerTests.coffee @@ -1,7 +1,7 @@ sinon = require('sinon') chai = require('chai') should = chai.should() -modulePath = "../../../app/js/ShareJsUpdateManager.js" +modulePath = "../../../../app/js/ShareJsUpdateManager.js" SandboxedModule = require('sandboxed-module') describe "ShareJsUpdateManager", -> diff --git a/services/document-updater/test/unit/coffee/ZipManager/ZipManager.coffee b/services/document-updater/test/unit/coffee/ZipManager/ZipManager.coffee index da7cdf4195..e477cfb23a 100644 --- a/services/document-updater/test/unit/coffee/ZipManager/ZipManager.coffee +++ b/services/document-updater/test/unit/coffee/ZipManager/ZipManager.coffee @@ -101,7 +101,7 @@ describe "ZipManager with RedisManager", -> @docLines = [] while @docLines.join('').length <= MIN_SIZE @docLines.push "this is a long line in a long document" - console.log "length of doclines", @docLines.join('').length + # console.log "length of doclines", @docLines.join('').length @callback = sinon.stub() @RedisManager.setDocument @doc_id, @docLines, @version, () => @callback()