overleaf/services/web/test/unit/coffee/infrastructure/LockManager/ReleasingTheLock.coffee

28 lines
794 B
CoffeeScript
Raw Normal View History

sinon = require('sinon')
assert = require('assert')
path = require('path')
modulePath = path.join __dirname, '../../../../../app/js/infrastructure/LockManager.js'
lockKey = "lock:web:{#{5678}}"
2018-05-04 08:22:33 -04:00
lockValue = "123456"
SandboxedModule = require('sandboxed-module')
describe 'LockManager - releasing the lock', ()->
2018-05-04 08:22:33 -04:00
deleteStub = sinon.stub().callsArgWith(4)
mocks =
"logger-sharelatex": log:->
"./RedisWrapper":
client: ()->
auth:->
2018-05-04 08:22:33 -04:00
eval:deleteStub
LockManager = SandboxedModule.require(modulePath, requires: mocks)
2018-05-04 08:22:33 -04:00
LockManager.unlockScript = "this is the unlock script"
it 'should put a all data into memory', (done)->
2018-05-04 08:22:33 -04:00
LockManager._releaseLock lockKey, lockValue, ->
deleteStub.calledWith(LockManager.unlockScript, 1, lockKey, lockValue).should.equal true
done()