mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 19:13:38 -05:00
modify LockManager test to avoid dependence on timing
This commit is contained in:
parent
d862227314
commit
57f6919485
1 changed files with 3 additions and 1 deletions
|
@ -35,9 +35,11 @@ describe 'LockManager - getting the lock', ->
|
||||||
describe "when the lock is initially set", ->
|
describe "when the lock is initially set", ->
|
||||||
beforeEach (done) ->
|
beforeEach (done) ->
|
||||||
startTime = Date.now()
|
startTime = Date.now()
|
||||||
|
tries = 0
|
||||||
@LockManager.LOCK_TEST_INTERVAL = 5
|
@LockManager.LOCK_TEST_INTERVAL = 5
|
||||||
@LockManager.tryLock = (doc_id, callback = (error, isFree) ->) ->
|
@LockManager.tryLock = (doc_id, callback = (error, isFree) ->) ->
|
||||||
if Date.now() - startTime < 20
|
if (Date.now() - startTime < 20) or (tries < 2)
|
||||||
|
tries = tries + 1
|
||||||
callback null, false
|
callback null, false
|
||||||
else
|
else
|
||||||
callback null, true
|
callback null, true
|
||||||
|
|
Loading…
Reference in a new issue