mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Get unit tests running and add one for ioredis
This commit is contained in:
parent
3b58e390fd
commit
89397e4c50
1 changed files with 15 additions and 7 deletions
|
@ -21,15 +21,17 @@ describe "index", ->
|
|||
@redis = SandboxedModule.require modulePath, requires:
|
||||
"redis-sentinel":@sentinel
|
||||
"redis":@normalRedis
|
||||
"ioredis": @ioredis =
|
||||
Cluster: class Cluster
|
||||
constructor: (@config) ->
|
||||
@auth_pass = "1234 pass"
|
||||
@endpoints = [
|
||||
{host: '127.0.0.1', port: 26379},
|
||||
{host: '127.0.0.1', port: 26380}
|
||||
]
|
||||
describe "sentinel", ->
|
||||
|
||||
describe "sentinel", ->
|
||||
beforeEach ->
|
||||
|
||||
@masterName = "my master"
|
||||
@sentinelOptions =
|
||||
endpoints:@endpoints
|
||||
|
@ -44,11 +46,10 @@ describe "index", ->
|
|||
|
||||
it "should pass the options correctly though", ->
|
||||
client = @redis.createClient @sentinelOptions
|
||||
@sentinel.createClient.calledWith(@endpoints, @masterName, auth_pass:@auth_pass).should.equal true
|
||||
@sentinel.createClient.calledWith(@endpoints, @masterName, {auth_pass:@auth_pass, retry_max_delay: 5000}).should.equal true
|
||||
client.should.equal @sentinelClient
|
||||
|
||||
describe "normal redis", ->
|
||||
|
||||
beforeEach ->
|
||||
@standardOpts =
|
||||
auth_pass: @auth_pass
|
||||
|
@ -63,9 +64,16 @@ describe "index", ->
|
|||
|
||||
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
|
||||
@normalRedis.createClient.calledWith(@standardOpts.port, @standardOpts.host, {auth_pass:@auth_pass, retry_max_delay: 5000}).should.equal true
|
||||
|
||||
describe "cluster", ->
|
||||
beforeEach ->
|
||||
@cluster = [{"mock": "cluster"}, { "mock": "cluster2"}]
|
||||
|
||||
it "should pass the options correctly though", ->
|
||||
client = @redis.createClient cluster: @cluster
|
||||
assert(client instanceof @ioredis.Cluster)
|
||||
client.config.should.deep.equal @cluster
|
||||
|
||||
describe "setting the password", ->
|
||||
beforeEach ->
|
||||
|
@ -81,10 +89,10 @@ describe "index", ->
|
|||
|
||||
it "should set the auth_pass from password if password exists for normal redis", ->
|
||||
client = @redis.createClient @standardOpts
|
||||
@normalRedis.createClient.calledWith(@standardOpts.port, @standardOpts.host, auth_pass:@auth_pass).should.equal true
|
||||
@normalRedis.createClient.calledWith(@standardOpts.port, @standardOpts.host, {auth_pass:@auth_pass, retry_max_delay: 5000}).should.equal true
|
||||
|
||||
it "should set the auth_pass from password if password exists for sentinal", ->
|
||||
client = @redis.createClient @sentinelOptions
|
||||
@sentinel.createClient.calledWith(@endpoints, @masterName, auth_pass:@auth_pass).should.equal true
|
||||
@sentinel.createClient.calledWith(@endpoints, @masterName, {auth_pass:@auth_pass, retry_max_delay: 5000}).should.equal true
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue