overleaf/services/document-updater/test/unit/coffee/LockManager/ReleasingTheLock.coffee

31 lines
875 B
CoffeeScript
Raw Normal View History

2014-02-12 05:40:42 -05:00
require('coffee-script')
sinon = require('sinon')
assert = require('assert')
path = require('path')
modulePath = path.join __dirname, '../../../../app/js/LockManager.js'
keys = require(path.join __dirname, '../../../../app/js/RedisKeyBuilder.js')
project_id = 1234
doc_id = 5678
SandboxedModule = require('sandboxed-module')
2014-02-12 05:40:42 -05:00
describe 'LockManager - releasing the lock', ()->
evalStub = sinon.stub().yields(1)
2014-02-12 05:40:42 -05:00
mocks =
"logger-sharelatex": log:->
2014-10-07 07:08:36 -04:00
"redis-sharelatex":
2014-02-12 05:40:42 -05:00
createClient : ()->
auth:->
eval: evalStub
"./Metrics": {inc: () ->}
2014-02-12 05:40:42 -05:00
LockManager = SandboxedModule.require(modulePath, requires: mocks)
2014-02-12 05:40:42 -05:00
it 'should put a all data into memory', (done)->
lockValue = "lock-value-stub"
LockManager.releaseLock doc_id, lockValue, ->
evalStub.calledWith(LockManager.unlockScript, 1, "Blocking:#{doc_id}", lockValue).should.equal true
2014-02-12 05:40:42 -05:00
done()