From a21f8a8004dc5d91d0b8640e040e3ce61169e94d Mon Sep 17 00:00:00 2001 From: James Allen Date: Wed, 26 Feb 2014 12:44:13 +0000 Subject: [PATCH] Add acceptance test for batch processing --- .../coffee/AppendingUpdatesTests.coffee | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/services/track-changes/test/acceptance/coffee/AppendingUpdatesTests.coffee b/services/track-changes/test/acceptance/coffee/AppendingUpdatesTests.coffee index e00b169782..a1cd7c89b3 100644 --- a/services/track-changes/test/acceptance/coffee/AppendingUpdatesTests.coffee +++ b/services/track-changes/test/acceptance/coffee/AppendingUpdatesTests.coffee @@ -132,3 +132,30 @@ describe "Appending doc ops to the history", -> expect(@updates[1].op).to.deep.equal { p: 6, i: "bar" } + + describe "when the updates need processing in batches", -> + before (done) -> + @doc_id = ObjectId().toString() + @user_id = ObjectId().toString() + updates = [] + @expectedOp = { p:0, i: "" } + for i in [0..250] + updates.push { + op: [{i: "a", p: 0}] + meta: { ts: Date.now(), user_id: @user_id } + v: i + } + @expectedOp.i = "a" + @expectedOp.i + + pushRawUpdates @doc_id, updates, (error) => + throw error if error? + flushAndGetCompressedUpdates @doc_id, (error, @updates) => + throw error if error? + done() + + it "should concat the compressed op into mongo", -> + expect(@updates[0].op).to.deep.equal @expectedOp + + it "should insert the correct version number into mongo", -> + expect(@updates[0].v).to.equal 250 +