mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #2 from sharelatex/bg-add-redis-cluster-refactor-test
add test for ioredis monkey patching
This commit is contained in:
commit
b3d1c03d4b
1 changed files with 21 additions and 0 deletions
|
@ -75,6 +75,27 @@ describe "index", ->
|
||||||
assert(client instanceof @ioredis.Cluster)
|
assert(client instanceof @ioredis.Cluster)
|
||||||
client.config.should.deep.equal @cluster
|
client.config.should.deep.equal @cluster
|
||||||
|
|
||||||
|
describe "monkey patch ioredis exec", ->
|
||||||
|
beforeEach ->
|
||||||
|
@callback = sinon.stub()
|
||||||
|
@results = []
|
||||||
|
@multiOrig = { exec: sinon.stub().yields(null, @results)}
|
||||||
|
@client = { multi: sinon.stub().returns(@multiOrig) }
|
||||||
|
@redis._monkeyPatchIoredisExec(@client)
|
||||||
|
@multi = @client.multi()
|
||||||
|
|
||||||
|
it "should return the old redis format for an array", ->
|
||||||
|
@results[0] = [null, 42]
|
||||||
|
@results[1] = [null, "foo"]
|
||||||
|
@multi.exec @callback
|
||||||
|
@callback.calledWith(null, [42, "foo"]).should.equal true
|
||||||
|
|
||||||
|
it "should return the old redis format when there is an error", ->
|
||||||
|
@results[0] = [null, 42]
|
||||||
|
@results[1] = ["error", "foo"]
|
||||||
|
@multi.exec @callback
|
||||||
|
@callback.calledWith("error").should.equal true
|
||||||
|
|
||||||
describe "setting the password", ->
|
describe "setting the password", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@standardOpts =
|
@standardOpts =
|
||||||
|
|
Loading…
Reference in a new issue