|
|
@@ -21,8 +21,7 @@ describe "index", ->
|
|
|
@redis = SandboxedModule.require modulePath, requires:
|
|
|
"redis-sentinel":@sentinel
|
|
|
"redis":@normalRedis
|
|
|
- @standardOpts =
|
|
|
- auth_pass: "my password"
|
|
|
+ @auth_pass = "1234 pass"
|
|
|
|
|
|
describe "sentinel", ->
|
|
|
|
|
|
@@ -32,34 +31,41 @@ describe "index", ->
|
|
|
{host: '127.0.0.1', port: 26380}
|
|
|
]
|
|
|
@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 @endpoints, @masterName, @standardOpts
|
|
|
+ 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 @endpoints, @masterName, @standardOpts
|
|
|
- @sentinel.createClient.calledWith(@endpoints, @masterName, @standardOpts).should.equal true
|
|
|
+ client = @redis.createClient @sentinelOptions
|
|
|
+ @sentinel.createClient.calledWith(@endpoints, @masterName, auth_pass:@auth_pass).should.equal true
|
|
|
client.should.equal @sentinelClient
|
|
|
|
|
|
describe "normal redis", ->
|
|
|
|
|
|
beforeEach ->
|
|
|
- @port = 1234
|
|
|
- @host = "redis.mysite.env"
|
|
|
+ @standardOpts =
|
|
|
+ auth_pass: @auth_pass
|
|
|
+ port: 1234
|
|
|
+ host: "redis.mysite.env"
|
|
|
|
|
|
it "should use the normal redis driver if a non array is passed", ->
|
|
|
-
|
|
|
- client = @redis.createClient @port, @host, @standardOpts
|
|
|
+ client = @redis.createClient @standardOpts
|
|
|
@sentinel.createClient.called.should.equal false
|
|
|
@normalRedis.createClient.called.should.equal true
|
|
|
client.should.equal @normalRedisClient
|
|
|
|
|
|
-
|
|
|
it "should use the normal redis driver if a non array is passed", ->
|
|
|
+ client = @redis.createClient @standardOpts
|
|
|
+ @normalRedis.createClient.calledWith(@standardOpts.port, @standardOpts.host, auth_pass:@auth_pass).should.equal true
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- client = @redis.createClient @port, @host, @standardOpts
|
|
|
- @normalRedis.createClient.calledWith(@port, @host, @standardOpts).should.equal true
|