ReleasingTheLock.coffee 797 B

12345678910111213141516171819202122232425262728
  1. require('coffee-script')
  2. sinon = require('sinon')
  3. assert = require('assert')
  4. path = require('path')
  5. modulePath = path.join __dirname, '../../../../app/js/LockManager.js'
  6. project_id = 1234
  7. doc_id = 5678
  8. SandboxedModule = require('sandboxed-module')
  9. describe 'LockManager - releasing the lock', ()->
  10. evalStub = sinon.stub().yields(1)
  11. mocks =
  12. "logger-sharelatex": log:->
  13. "redis-sharelatex":
  14. createClient : ()->
  15. auth:->
  16. eval: evalStub
  17. "./Metrics": {inc: () ->}
  18. LockManager = SandboxedModule.require(modulePath, requires: mocks)
  19. it 'should put a all data into memory', (done)->
  20. lockValue = "lock-value-stub"
  21. LockManager.releaseLock doc_id, lockValue, ->
  22. evalStub.calledWith(LockManager.unlockScript, 1, "Blocking:#{doc_id}", lockValue).should.equal true
  23. done()