mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
update tests
This commit is contained in:
parent
1a0550364d
commit
fcb72b9bf7
5 changed files with 17 additions and 14 deletions
12
services/document-updater/package-lock.json
generated
12
services/document-updater/package-lock.json
generated
|
@ -853,9 +853,9 @@
|
|||
}
|
||||
},
|
||||
"acorn": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.0.tgz",
|
||||
"integrity": "sha512-gac8OEcQ2Li1dxIEWGZzsp2BitJxwkwcOm0zHAJLcPJaVvm58FRnk6RkuLRpU1EujipU2ZFODv2P9DLMfnV8mw=="
|
||||
"version": "6.4.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz",
|
||||
"integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA=="
|
||||
},
|
||||
"agent-base": {
|
||||
"version": "6.0.0",
|
||||
|
@ -2183,9 +2183,9 @@
|
|||
"integrity": "sha512-2403MfnVypWSNIEpmQ26/ObZ5kSUx37E8NHRvriw0+I8Sne7k0HGuLGCk0OrCqURh4UIygD0cSsYq+Ll+kzNqA=="
|
||||
},
|
||||
"metrics-sharelatex": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/metrics-sharelatex/-/metrics-sharelatex-2.5.1.tgz",
|
||||
"integrity": "sha512-C2gmkl/tUnq3IlSX/x3dixGhdvfD6H9FR9mBf9lnkeyy2arafxhCU6u+1IQj6byjBM7vGpYHyjwWnmoi3Vb+ZQ==",
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/metrics-sharelatex/-/metrics-sharelatex-2.6.2.tgz",
|
||||
"integrity": "sha512-bOLfkSCexiPgB96hdXhoOWyvvrwscgjeZPEqdcJ7BTGxY59anzvymNf5hTGJ1RtS4sblDKxITw3L5a+gYKhRYQ==",
|
||||
"requires": {
|
||||
"@google-cloud/debug-agent": "^3.0.0",
|
||||
"@google-cloud/profiler": "^0.2.3",
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
"express": "3.11.0",
|
||||
"lodash": "^4.17.13",
|
||||
"logger-sharelatex": "^1.7.0",
|
||||
"metrics-sharelatex": "^2.5.1",
|
||||
"metrics-sharelatex": "^2.6.2",
|
||||
"mongojs": "^2.6.0",
|
||||
"redis-sharelatex": "^1.0.11",
|
||||
"request": "^2.47.0",
|
||||
|
|
|
@ -26,6 +26,7 @@ describe "ProjectHistoryRedisManager", ->
|
|||
createClient: () => @rclient
|
||||
"logger-sharelatex":
|
||||
log:->
|
||||
"./Metrics": @metrics = { summary: sinon.stub()}
|
||||
globals:
|
||||
JSON: @JSON = JSON
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ describe "RealTimeRedisManager", ->
|
|||
auth: () ->
|
||||
exec: sinon.stub()
|
||||
@rclient.multi = () => @rclient
|
||||
@pubsubClient =
|
||||
@pubsubClient =
|
||||
publish: sinon.stub()
|
||||
@RealTimeRedisManager = SandboxedModule.require modulePath, requires:
|
||||
"redis-sharelatex": createClient: (config) => if (config.name is 'pubsub') then @pubsubClient else @rclient
|
||||
|
@ -25,11 +25,12 @@ describe "RealTimeRedisManager", ->
|
|||
"logger-sharelatex": { log: () -> }
|
||||
"crypto": @crypto = { randomBytes: sinon.stub().withArgs(4).returns(Buffer.from([0x1, 0x2, 0x3, 0x4])) }
|
||||
"os": @os = {hostname: sinon.stub().returns("somehost")}
|
||||
"./Metrics": @metrics = { summary: sinon.stub()}
|
||||
|
||||
@doc_id = "doc-id-123"
|
||||
@project_id = "project-id-123"
|
||||
@callback = sinon.stub()
|
||||
|
||||
|
||||
describe "getPendingUpdatesForDoc", ->
|
||||
beforeEach ->
|
||||
@rclient.lrange = sinon.stub()
|
||||
|
@ -44,7 +45,7 @@ describe "RealTimeRedisManager", ->
|
|||
@jsonUpdates = @updates.map (update) -> JSON.stringify update
|
||||
@rclient.exec = sinon.stub().callsArgWith(0, null, [@jsonUpdates])
|
||||
@RealTimeRedisManager.getPendingUpdatesForDoc @doc_id, @callback
|
||||
|
||||
|
||||
it "should get the pending updates", ->
|
||||
@rclient.lrange
|
||||
.calledWith("PendingUpdates:#{@doc_id}", 0, 7)
|
||||
|
@ -75,10 +76,10 @@ describe "RealTimeRedisManager", ->
|
|||
beforeEach ->
|
||||
@rclient.llen = sinon.stub().yields(null, @length = 3)
|
||||
@RealTimeRedisManager.getUpdatesLength @doc_id, @callback
|
||||
|
||||
|
||||
it "should look up the length", ->
|
||||
@rclient.llen.calledWith("PendingUpdates:#{@doc_id}").should.equal true
|
||||
|
||||
|
||||
it "should return the length", ->
|
||||
@callback.calledWith(null, @length).should.equal true
|
||||
|
||||
|
@ -86,6 +87,6 @@ describe "RealTimeRedisManager", ->
|
|||
beforeEach ->
|
||||
@message_id = "doc:somehost:01020304-0"
|
||||
@RealTimeRedisManager.sendData({op: "thisop"})
|
||||
|
||||
|
||||
it "should send the op with a message id", ->
|
||||
@pubsubClient.publish.calledWith("applied-ops", JSON.stringify({op:"thisop",_id:@message_id})).should.equal true
|
||||
@pubsubClient.publish.calledWith("applied-ops", JSON.stringify({op:"thisop",_id:@message_id})).should.equal true
|
||||
|
|
|
@ -48,6 +48,7 @@ describe "RedisManager", ->
|
|||
createClient: () => @rclient
|
||||
"./Metrics": @metrics =
|
||||
inc: sinon.stub()
|
||||
summary: sinon.stub()
|
||||
Timer: class Timer
|
||||
constructor: () ->
|
||||
this.start = new Date()
|
||||
|
|
Loading…
Reference in a new issue