|
|
@@ -11,16 +11,11 @@ describe "index", ->
|
|
|
beforeEach ->
|
|
|
|
|
|
@settings = {}
|
|
|
- @sentinelClient =
|
|
|
- set: ->
|
|
|
- on: ->
|
|
|
@normalRedisClient =
|
|
|
get: ->
|
|
|
on: ->
|
|
|
@ioredisConstructor = ioredisConstructor = sinon.stub()
|
|
|
|
|
|
- @sentinel =
|
|
|
- createClient: sinon.stub().returns(@sentinelClient)
|
|
|
@normalRedis =
|
|
|
createClient: sinon.stub().returns(@normalRedisClient)
|
|
|
@ioredis = class IoRedis
|
|
|
@@ -30,33 +25,9 @@ describe "index", ->
|
|
|
constructor: (@config, @options) ->
|
|
|
on: sinon.stub()
|
|
|
@redis = SandboxedModule.require modulePath, requires:
|
|
|
- "redis-sentinel":@sentinel
|
|
|
"redis":@normalRedis
|
|
|
"ioredis": @ioredis
|
|
|
@auth_pass = "1234 pass"
|
|
|
- @endpoints = [
|
|
|
- {host: '127.0.0.1', port: 26379},
|
|
|
- {host: '127.0.0.1', port: 26380}
|
|
|
- ]
|
|
|
-
|
|
|
- describe "sentinel", ->
|
|
|
- beforeEach ->
|
|
|
- @masterName = "my master"
|
|
|
- @sentinelOptions =
|
|
|
- endpoints:@endpoints
|
|
|
- masterName:@masterName
|
|
|
- auth_pass:@auth_pass
|
|
|
-
|
|
|
- it "should use sentinal if the first argument in an array", ->
|
|
|
- client = @redis.createClient @sentinelOptions
|
|
|
- @sentinel.createClient.called.should.equal true
|
|
|
- @normalRedis.createClient.called.should.equal false
|
|
|
- client.should.equal @sentinelClient
|
|
|
-
|
|
|
- it "should pass the options correctly though", ->
|
|
|
- client = @redis.createClient @sentinelOptions
|
|
|
- @sentinel.createClient.calledWith(@endpoints, @masterName, {auth_pass:@auth_pass, retry_max_delay: 5000}).should.equal true
|
|
|
- client.should.equal @sentinelClient
|
|
|
|
|
|
describe "single node redis", ->
|
|
|
beforeEach ->
|
|
|
@@ -67,7 +38,6 @@ describe "index", ->
|
|
|
|
|
|
it "should use the ioredis driver in single-instance mode if a non array is passed", ->
|
|
|
client = @redis.createClient @standardOpts
|
|
|
- @sentinel.createClient.called.should.equal false
|
|
|
@normalRedis.createClient.called.should.equal false
|
|
|
assert.equal(client.constructor, @ioredis)
|
|
|
|