mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
fca95b5b27
- 1.1.3 build scripts - add env vars for configuring s3 - add docker file
36 lines
1.3 KiB
CoffeeScript
36 lines
1.3 KiB
CoffeeScript
sinon = require "sinon"
|
|
chai = require("chai")
|
|
chai.should()
|
|
expect = chai.expect
|
|
mongojs = require "../../../app/js/mongojs"
|
|
ObjectId = mongojs.ObjectId
|
|
Settings = require "settings-sharelatex"
|
|
LockManager = require "../../../app/js/LockManager"
|
|
rclient = require("redis").createClient(Settings.redis.history) # Only works locally for now
|
|
TrackChangesApp = require "./helpers/TrackChangesApp"
|
|
|
|
describe "Locking document", ->
|
|
|
|
before (done)->
|
|
TrackChangesApp.ensureRunning done
|
|
|
|
describe "when the lock has expired in redis", ->
|
|
before (done) ->
|
|
LockManager.LOCK_TTL = 1 # second
|
|
LockManager.runWithLock "doc123", (releaseA) =>
|
|
# we create a lock A and allow it to expire in redis
|
|
setTimeout () ->
|
|
# now we create a new lock B and try to release A
|
|
LockManager.runWithLock "doc123", (releaseB) =>
|
|
releaseA() # try to release lock A to see if it wipes out lock B
|
|
, (error) ->
|
|
# we never release lock B so nothing should happen here
|
|
, 1500 # enough time to wait until the lock has expired
|
|
, (error) ->
|
|
# we get here after trying to release lock A
|
|
done()
|
|
|
|
it "the new lock should not be removed by the expired locker", (done) ->
|
|
LockManager.checkLock "doc123", (err, isFree) ->
|
|
expect(isFree).to.equal false
|
|
done()
|