Files
overleaf-cep/services/web/test/unit/src/infrastructure/LockManager/ReleasingTheLock.js
T
Jakob Ackermann 5e773ce950 Merge pull request #4101 from overleaf/ae-settings-module
Migrate from `settings-sharelatex` to `@overleaf/settings`

GitOrigin-RevId: 9a298ba26382180c1351683c5fddc9004418c1e6
2021-07-08 02:08:28 +00:00

59 lines
1.6 KiB
JavaScript

/* eslint-disable
max-len,
no-unused-vars,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const sinon = require('sinon')
const assert = require('assert')
const path = require('path')
const modulePath = path.join(
__dirname,
'../../../../../app/src/infrastructure/LockManager.js'
)
const lockKey = `lock:web:{${5678}}`
const lockValue = '123456'
const SandboxedModule = require('sandboxed-module')
describe('LockManager - releasing the lock', function () {
const deleteStub = sinon.stub().callsArgWith(4)
const mocks = {
'@overleaf/settings': {
redis: {},
lockManager: {
lockTestInterval: 50,
maxTestInterval: 1000,
maxLockWaitTime: 10000,
redisLockExpiry: 30,
slowExecutionThreshold: 5000,
},
},
'@overleaf/metrics': {},
'./RedisWrapper': {
client() {
return {
auth() {},
eval: deleteStub,
}
},
},
}
const LockManager = SandboxedModule.require(modulePath, { requires: mocks })
LockManager.unlockScript = 'this is the unlock script'
it('should put a all data into memory', function (done) {
return LockManager._releaseLock(lockKey, lockValue, () => {
deleteStub
.calledWith(LockManager.unlockScript, 1, lockKey, lockValue)
.should.equal(true)
return done()
})
})
})