mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
96cd1c869e
Clean up attempts to connect to Mongo and Redis in unit tests GitOrigin-RevId: 396813a04fc2aaf39a07e28613f8f1e0a7a2db8f
24 lines
737 B
JavaScript
24 lines
737 B
JavaScript
const Settings = require('settings-sharelatex')
|
|
const redis = require('redis-sharelatex')
|
|
|
|
if (
|
|
typeof global.beforeEach === 'function' &&
|
|
process.argv.join(' ').match(/unit/)
|
|
) {
|
|
throw new Error(
|
|
'It looks like unit tests are running, but you are connecting to Redis. Missing a stub?'
|
|
)
|
|
}
|
|
|
|
// A per-feature interface to Redis,
|
|
// looks up the feature in `settings.redis`
|
|
// and returns an appropriate client.
|
|
// Necessary because we don't want to migrate web over
|
|
// to redis-cluster all at once.
|
|
module.exports = {
|
|
// feature = 'websessions' | 'ratelimiter' | ...
|
|
client(feature) {
|
|
const redisFeatureSettings = Settings.redis[feature] || Settings.redis.web
|
|
return redis.createClient(redisFeatureSettings)
|
|
}
|
|
}
|