ReleasingTheLock.coffee 869 B

123456789101112131415161718192021222324252627282930
  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. "./RedisKeyBuilder":
  14. blockingKey: ({doc_id}) -> "Blocking:#{doc_id}"
  15. "./RedisBackend":
  16. createClient : ()->
  17. auth:->
  18. eval: evalStub
  19. "./Metrics": {inc: () ->}
  20. LockManager = SandboxedModule.require(modulePath, requires: mocks)
  21. it 'should put a all data into memory', (done)->
  22. lockValue = "lock-value-stub"
  23. LockManager.releaseLock doc_id, lockValue, ->
  24. evalStub.calledWith(LockManager.unlockScript, 1, "Blocking:#{doc_id}", lockValue).should.equal true
  25. done()