|
@@ -224,8 +224,11 @@ describe "RedisBackend", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
|
@client.SECONDARY_TIMEOUT = 10
|
|
@client.SECONDARY_TIMEOUT = 10
|
|
|
@content = "bar"
|
|
@content = "bar"
|
|
|
- @rclient_redis.get = sinon.stub()
|
|
|
|
|
- @rclient_redis.get.withArgs("doclines:#{@doc_id}").yields(null, @content)
|
|
|
|
|
|
|
+ @rclient_redis.get = (key, cb) =>
|
|
|
|
|
+ key.should.equal "doclines:#{@doc_id}"
|
|
|
|
|
+ setTimeout () =>
|
|
|
|
|
+ cb(null, @content)
|
|
|
|
|
+ , @client.SECONDARY_TIMEOUT * 3 # If the secondary errors first, don't affect the primary result
|
|
|
@rclient_ioredis.get = (key, cb) =>
|
|
@rclient_ioredis.get = (key, cb) =>
|
|
|
key.should.equal "doclines:{#{@doc_id}}"
|
|
key.should.equal "doclines:{#{@doc_id}}"
|
|
|
setTimeout () =>
|
|
setTimeout () =>
|
|
@@ -236,8 +239,11 @@ describe "RedisBackend", ->
|
|
|
|
|
|
|
|
it "should log out an error for the backend", ->
|
|
it "should log out an error for the backend", ->
|
|
|
@logger.error
|
|
@logger.error
|
|
|
- .calledWith({err: new Error("backend timed out")}, "error in redis backend")
|
|
|
|
|
|
|
+ .calledWith({err: new Error("backend timed out")}, "backend timed out")
|
|
|
.should.equal true
|
|
.should.equal true
|
|
|
|
|
+
|
|
|
|
|
+ it "should return the primary result", ->
|
|
|
|
|
+ @result.should.equal @content
|
|
|
|
|
|
|
|
describe "when the primary takes longer than SECONDARY_TIMEOUT", ->
|
|
describe "when the primary takes longer than SECONDARY_TIMEOUT", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
@@ -394,7 +400,10 @@ describe "RedisBackend", ->
|
|
|
describe "when the secondary takes longer than SECONDARY_TIMEOUT", ->
|
|
describe "when the secondary takes longer than SECONDARY_TIMEOUT", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
|
@rclient_redis.get = sinon.stub()
|
|
@rclient_redis.get = sinon.stub()
|
|
|
- @rclient_redis.exec = sinon.stub().yields(null, [@doclines, @version])
|
|
|
|
|
|
|
+ @rclient_redis.exec = (cb) =>
|
|
|
|
|
+ setTimeout () =>
|
|
|
|
|
+ cb(null, [@doclines, @version])
|
|
|
|
|
+ , 30 # If secondary errors first, don't affect the primary result
|
|
|
@rclient_ioredis.get = sinon.stub()
|
|
@rclient_ioredis.get = sinon.stub()
|
|
|
@rclient_ioredis.exec = (cb) =>
|
|
@rclient_ioredis.exec = (cb) =>
|
|
|
setTimeout () =>
|
|
setTimeout () =>
|
|
@@ -410,8 +419,11 @@ describe "RedisBackend", ->
|
|
|
|
|
|
|
|
it "should log out an error for the backend", ->
|
|
it "should log out an error for the backend", ->
|
|
|
@logger.error
|
|
@logger.error
|
|
|
- .calledWith({err: new Error("backend timed out")}, "error in redis backend")
|
|
|
|
|
|
|
+ .calledWith({err: new Error("backend timed out")}, "backend timed out")
|
|
|
.should.equal true
|
|
.should.equal true
|
|
|
|
|
+
|
|
|
|
|
+ it "should return the primary result", ->
|
|
|
|
|
+ @result.should.deep.equal [@doclines, @version]
|
|
|
|
|
|
|
|
describe "when the primary takes longer than SECONDARY_TIMEOUT", ->
|
|
describe "when the primary takes longer than SECONDARY_TIMEOUT", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|