From 8e210fe44140ca5fee302410924b2282068f72e2 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Tue, 21 Apr 2020 14:41:30 +0100 Subject: [PATCH] update unit tests --- .../coffee/ApplyingUpdatesToADocTests.coffee | 13 +++++++------ .../ApplyingUpdatesToProjectStructureTests.coffee | 14 +++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToADocTests.coffee b/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToADocTests.coffee index 0b28dea7a7..489f8d98eb 100644 --- a/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToADocTests.coffee +++ b/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToADocTests.coffee @@ -4,7 +4,8 @@ chai.should() expect = chai.expect async = require "async" Settings = require('settings-sharelatex') -rclient_history = require("redis-sharelatex").createClient(Settings.redis.history) +rclient_history = require("redis-sharelatex").createClient(Settings.redis.history) # note: this is track changes, not project-history +rclient_project_history = require("redis-sharelatex").createClient(Settings.redis.project_history) rclient_du = require("redis-sharelatex").createClient(Settings.redis.documentupdater) Keys = Settings.redis.documentupdater.key_schema HistoryKeys = Settings.redis.history.key_schema @@ -65,14 +66,14 @@ describe "Applying updates to a doc", -> return null it "should push the applied updates to the project history changes api", (done) -> - rclient_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => + rclient_project_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => throw error if error? JSON.parse(updates[0]).op.should.deep.equal @update.op done() return null it "should set the first op timestamp", (done) -> - rclient_history.get ProjectHistoryKeys.projectHistoryFirstOpTimestamp({@project_id}), (error, result) => + rclient_project_history.get ProjectHistoryKeys.projectHistoryFirstOpTimestamp({@project_id}), (error, result) => throw error if error? result.should.be.within(@startTime, Date.now()) @firstOpTimestamp = result @@ -90,7 +91,7 @@ describe "Applying updates to a doc", -> return null it "should not change the first op timestamp", (done) -> - rclient_history.get ProjectHistoryKeys.projectHistoryFirstOpTimestamp({@project_id}), (error, result) => + rclient_project_history.get ProjectHistoryKeys.projectHistoryFirstOpTimestamp({@project_id}), (error, result) => throw error if error? result.should.equal @firstOpTimestamp done() @@ -130,7 +131,7 @@ describe "Applying updates to a doc", -> return null it "should push the applied updates to the project history changes api", (done) -> - rclient_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => + rclient_project_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => JSON.parse(updates[0]).op.should.deep.equal @update.op done() return null @@ -164,7 +165,7 @@ describe "Applying updates to a doc", -> return null it "should push the applied updates to the project history changes api", (done) -> - rclient_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => + rclient_project_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => JSON.parse(updates[0]).op.should.deep.equal @update.op done() return null diff --git a/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToProjectStructureTests.coffee b/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToProjectStructureTests.coffee index cbb9fd9ea5..e18aa2e6a1 100644 --- a/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToProjectStructureTests.coffee +++ b/services/document-updater/test/acceptance/coffee/ApplyingUpdatesToProjectStructureTests.coffee @@ -2,7 +2,7 @@ sinon = require "sinon" chai = require("chai") chai.should() Settings = require('settings-sharelatex') -rclient_history = require("redis-sharelatex").createClient(Settings.redis.history) +rclient_project_history = require("redis-sharelatex").createClient(Settings.redis.project_history) ProjectHistoryKeys = Settings.redis.project_history.key_schema MockProjectHistoryApi = require "./helpers/MockProjectHistoryApi" @@ -30,7 +30,7 @@ describe "Applying updates to a project's structure", -> setTimeout done, 200 it "should push the applied file renames to the project history api", (done) -> - rclient_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => + rclient_project_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => throw error if error? update = JSON.parse(updates[0]) @@ -61,7 +61,7 @@ describe "Applying updates to a project's structure", -> return null it "should push the applied doc renames to the project history api", (done) -> - rclient_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => + rclient_project_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => throw error if error? update = JSON.parse(updates[0]) @@ -97,7 +97,7 @@ describe "Applying updates to a project's structure", -> return null it "should push the applied doc renames to the project history api", (done) -> - rclient_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => + rclient_project_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => throw error if error? update = JSON.parse(updates[0]) @@ -141,7 +141,7 @@ describe "Applying updates to a project's structure", -> return null it "should push the applied doc renames to the project history api", (done) -> - rclient_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => + rclient_project_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => throw error if error? update = JSON.parse(updates[0]) @@ -194,7 +194,7 @@ describe "Applying updates to a project's structure", -> return null it "should push the file addition to the project history api", (done) -> - rclient_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => + rclient_project_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => throw error if error? update = JSON.parse(updates[0]) @@ -222,7 +222,7 @@ describe "Applying updates to a project's structure", -> return null it "should push the doc addition to the project history api", (done) -> - rclient_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => + rclient_project_history.lrange ProjectHistoryKeys.projectHistoryOps({@project_id}), 0, -1, (error, updates) => throw error if error? update = JSON.parse(updates[0])