ReleasingTheLock.coffee 794 B

123456789101112131415161718192021222324252627
  1. sinon = require('sinon')
  2. assert = require('assert')
  3. path = require('path')
  4. modulePath = path.join __dirname, '../../../../../app/js/infrastructure/LockManager.js'
  5. lockKey = "lock:web:{#{5678}}"
  6. lockValue = "123456"
  7. SandboxedModule = require('sandboxed-module')
  8. describe 'LockManager - releasing the lock', ()->
  9. deleteStub = sinon.stub().callsArgWith(4)
  10. mocks =
  11. "logger-sharelatex": log:->
  12. "./RedisWrapper":
  13. client: ()->
  14. auth:->
  15. eval:deleteStub
  16. LockManager = SandboxedModule.require(modulePath, requires: mocks)
  17. LockManager.unlockScript = "this is the unlock script"
  18. it 'should put a all data into memory', (done)->
  19. LockManager._releaseLock lockKey, lockValue, ->
  20. deleteStub.calledWith(LockManager.unlockScript, 1, lockKey, lockValue).should.equal true
  21. done()