From 6923ca0d5fad7a9bedfc1142334d625ba16b0c46 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Tue, 25 Apr 2017 15:34:32 +0100 Subject: [PATCH] add test for ioredis monkey patching --- libraries/redis-wrapper/test.coffee | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libraries/redis-wrapper/test.coffee b/libraries/redis-wrapper/test.coffee index 883ddfa346..0dc5c8ad74 100644 --- a/libraries/redis-wrapper/test.coffee +++ b/libraries/redis-wrapper/test.coffee @@ -75,6 +75,27 @@ describe "index", -> assert(client instanceof @ioredis.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", -> beforeEach -> @standardOpts =