2016-12-19 10:12:22 -05:00
|
|
|
assert = require("chai").assert
|
|
|
|
sinon = require('sinon')
|
|
|
|
chai = require('chai')
|
|
|
|
should = chai.should()
|
|
|
|
expect = chai.expect
|
|
|
|
modulePath = "../../../../app/js/infrastructure/RedisWrapper.js"
|
|
|
|
SandboxedModule = require('sandboxed-module')
|
|
|
|
|
|
|
|
describe 'RedisWrapper', ->
|
|
|
|
|
|
|
|
beforeEach ->
|
2017-05-04 10:22:54 -04:00
|
|
|
@settings = { redis: {} }
|
2016-12-19 10:12:22 -05:00
|
|
|
@redis =
|
2017-05-04 10:22:54 -04:00
|
|
|
createClient: sinon.stub()
|
2016-12-19 10:12:22 -05:00
|
|
|
@RedisWrapper = SandboxedModule.require modulePath, requires:
|
|
|
|
'settings-sharelatex': @settings
|
|
|
|
'redis-sharelatex': @redis
|
|
|
|
|
|
|
|
describe 'client', ->
|
2017-05-04 10:22:54 -04:00
|
|
|
it "should use the feature settings if present", ->
|
|
|
|
@settings.redis =
|
|
|
|
my_feature:
|
|
|
|
port:"23456"
|
|
|
|
host:"otherhost"
|
|
|
|
password: "banana"
|
|
|
|
@RedisWrapper.client("my_feature")
|
|
|
|
@redis.createClient.calledWith(@settings.redis.my_feature).should.equal true
|
|
|
|
|
|
|
|
it "should use the web settings if feature not present", ->
|
|
|
|
@settings.redis =
|
|
|
|
web:
|
|
|
|
port:"43"
|
|
|
|
host:"otherhost"
|
|
|
|
password: "banana"
|
|
|
|
@RedisWrapper.client("my_feature")
|
|
|
|
@redis.createClient.calledWith(@settings.redis.web).should.equal true
|