fix acceptance test to work with redis cluster too

This commit is contained in:
Brian Gough 2017-04-27 10:42:43 +01:00
parent dc77bc207d
commit 64aef0b55a

View file

@ -7,6 +7,7 @@ Settings = require('settings-sharelatex')
rclient_history = require("redis-sharelatex").createClient(Settings.redis.history) rclient_history = require("redis-sharelatex").createClient(Settings.redis.history)
rclient_du = require("redis-sharelatex").createClient(Settings.redis.documentupdater) rclient_du = require("redis-sharelatex").createClient(Settings.redis.documentupdater)
Keys = Settings.redis.documentupdater.key_schema Keys = Settings.redis.documentupdater.key_schema
HistoryKeys = Settings.redis.history.key_schema
MockTrackChangesApi = require "./helpers/MockTrackChangesApi" MockTrackChangesApi = require "./helpers/MockTrackChangesApi"
MockWebApi = require "./helpers/MockWebApi" MockWebApi = require "./helpers/MockWebApi"
@ -49,10 +50,10 @@ describe "Applying updates to a doc", ->
done() done()
it "should push the applied updates to the track changes api", (done) -> it "should push the applied updates to the track changes api", (done) ->
rclient_history.lrange "UncompressedHistoryOps:#{@doc_id}", 0, -1, (error, updates) => rclient_history.lrange HistoryKeys.uncompressedHistoryOps({@doc_id}), 0, -1, (error, updates) =>
throw error if error? throw error if error?
JSON.parse(updates[0]).op.should.deep.equal @update.op JSON.parse(updates[0]).op.should.deep.equal @update.op
rclient_history.sismember "DocsWithHistoryOps:#{@project_id}", @doc_id, (error, result) => rclient_history.sismember HistoryKeys.docsWithHistoryOps({@project_id}), @doc_id, (error, result) =>
throw error if error? throw error if error?
result.should.equal 1 result.should.equal 1
done() done()
@ -82,9 +83,9 @@ describe "Applying updates to a doc", ->
done() done()
it "should push the applied updates to the track changes api", (done) -> it "should push the applied updates to the track changes api", (done) ->
rclient_history.lrange "UncompressedHistoryOps:#{@doc_id}", 0, -1, (error, updates) => rclient_history.lrange HistoryKeys.uncompressedHistoryOps({@doc_id}), 0, -1, (error, updates) =>
JSON.parse(updates[0]).op.should.deep.equal @update.op JSON.parse(updates[0]).op.should.deep.equal @update.op
rclient_history.sismember "DocsWithHistoryOps:#{@project_id}", @doc_id, (error, result) => rclient_history.sismember HistoryKeys.docsWithHistoryOps({@project_id}), @doc_id, (error, result) =>
result.should.equal 1 result.should.equal 1
done() done()
@ -127,12 +128,12 @@ describe "Applying updates to a doc", ->
done() done()
it "should push the applied updates to the track changes api", (done) -> it "should push the applied updates to the track changes api", (done) ->
rclient_history.lrange "UncompressedHistoryOps:#{@doc_id}", 0, -1, (error, updates) => rclient_history.lrange HistoryKeys.uncompressedHistoryOps({@doc_id}), 0, -1, (error, updates) =>
updates = (JSON.parse(u) for u in updates) updates = (JSON.parse(u) for u in updates)
for appliedUpdate, i in @updates for appliedUpdate, i in @updates
appliedUpdate.op.should.deep.equal updates[i].op appliedUpdate.op.should.deep.equal updates[i].op
rclient_history.sismember "DocsWithHistoryOps:#{@project_id}", @doc_id, (error, result) => rclient_history.sismember HistoryKeys.docsWithHistoryOps({@project_id}), @doc_id, (error, result) =>
result.should.equal 1 result.should.equal 1
done() done()