From 1bb12a5035e5b08e191b1084821377beea5e4d06 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Wed, 11 Dec 2019 14:43:59 +0000 Subject: [PATCH] allow pending updates to clear in acceptance tests --- .../coffee/helpers/DocUpdaterClient.coffee | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/services/document-updater/test/acceptance/coffee/helpers/DocUpdaterClient.coffee b/services/document-updater/test/acceptance/coffee/helpers/DocUpdaterClient.coffee index 17067b5bf4..b78f2aa7dd 100644 --- a/services/document-updater/test/acceptance/coffee/helpers/DocUpdaterClient.coffee +++ b/services/document-updater/test/acceptance/coffee/helpers/DocUpdaterClient.coffee @@ -33,7 +33,17 @@ module.exports = DocUpdaterClient = do (update) -> jobs.push (callback) -> DocUpdaterClient.sendUpdate project_id, doc_id, update, callback - async.series jobs, callback + async.series jobs, (err) -> + DocUpdaterClient.waitForPendingUpdates project_id, doc_id, callback + + waitForPendingUpdates: (project_id, doc_id, callback) -> + async.retry {times: 30, interval: 100}, (cb) -> + rclient.llen keys.pendingUpdates({doc_id}), (err, length) -> + if length > 0 + cb(new Error("updates still pending")) + else + cb() + , callback getDoc: (project_id, doc_id, callback = (error, res, body) ->) -> request.get "http://localhost:3003/project/#{project_id}/doc/#{doc_id}", (error, res, body) ->