[misc] bump logger-sharelatex to version 2.2.0

This commit is contained in:
Christopher Hoskin 2020-08-12 15:17:06 +01:00
parent 0c83e19863
commit d1da5e43af
26 changed files with 277 additions and 293 deletions

View file

@ -1,2 +1,5 @@
node_modules
forever
# managed by dev-environment$ bin/update_build_scripts
.npmrc

View file

@ -24,8 +24,8 @@ module.exports = {
unArchiveAllDocs,
unarchiveDoc,
destroyAllDocs,
destroyDoc
}
destroyDoc,
},
}
async function archiveAllDocs(projectId) {
@ -61,7 +61,7 @@ async function archiveDoc(projectId, doc) {
const json = JSON.stringify({
lines: doc.lines,
ranges: doc.ranges,
schema_v: 1
schema_v: 1,
})
// this should never happen, but protects against memory-corruption errors that
@ -75,7 +75,7 @@ async function archiveDoc(projectId, doc) {
const md5 = crypto.createHash('md5').update(json).digest('hex')
const stream = Streamifier.createReadStream(json)
await PersistorManager.sendStream(settings.docstore.bucket, key, stream, {
sourceMd5: md5
sourceMd5: md5,
})
await MongoManager.markDocAsArchived(doc._id, doc.rev)
}
@ -115,7 +115,7 @@ async function unarchiveDoc(projectId, docId) {
throw new Errors.Md5MismatchError('md5 mismatch when downloading doc', {
key,
sourceMd5,
md5
md5,
})
}
@ -155,7 +155,7 @@ async function destroyDoc(projectId, docId) {
'removing doc from mongo and persistor'
)
const doc = await MongoManager.findDoc(projectId, docId, {
inS3: 1
inS3: 1,
})
if (!doc) {
throw new Errors.NotFoundError('Doc not found in Mongo')

View file

@ -103,7 +103,7 @@ module.exports = DocManager = {
deleted: true,
version: true,
ranges: true,
inS3: true
inS3: true,
},
function (err, doc) {
if (err != null) {
@ -175,7 +175,7 @@ module.exports = DocManager = {
lines: true,
version: true,
ranges: true,
inS3: true
inS3: true,
},
function (err, doc) {
let updateLines, updateRanges, updateVersion
@ -238,7 +238,7 @@ module.exports = DocManager = {
project_id,
doc_id,
oldVersion: doc != null ? doc.version : undefined,
newVersion: version
newVersion: version,
},
'updating doc version'
)
@ -288,5 +288,5 @@ module.exports = DocManager = {
}
return MongoManager.markDocAsDeleted(project_id, doc_id, callback)
})
}
},
}

View file

@ -6,5 +6,5 @@ class Md5MismatchError extends OError {}
module.exports = {
Md5MismatchError,
...Errors
...Errors,
}

View file

@ -26,11 +26,11 @@ module.exports = {
const url = `http://localhost:${port}/project/${project_id}/doc/${doc_id}`
const lines = [
'smoke test - delete me',
`${crypto.randomBytes(32).toString('hex')}`
`${crypto.randomBytes(32).toString('hex')}`,
]
const getOpts = () => ({
url,
timeout: 3000
timeout: 3000,
})
logger.log({ lines, url, doc_id, project_id }, 'running health check')
const jobs = [
@ -61,8 +61,8 @@ module.exports = {
})
},
(cb) => db.docs.remove({ _id: doc_id, project_id }, cb),
(cb) => db.docOps.remove({ doc_id }, cb)
(cb) => db.docOps.remove({ doc_id }, cb),
]
return async.series(jobs, callback)
}
},
}

View file

@ -157,7 +157,7 @@ module.exports = HttpController = {
}
return res.json({
modified,
rev
rev,
})
}
)
@ -259,5 +259,5 @@ module.exports = HttpController = {
return res.sendStatus(200)
}
})
}
},
}

View file

@ -24,7 +24,7 @@ module.exports = MongoManager = {
return db.docs.find(
{
_id: ObjectId(doc_id.toString()),
project_id: ObjectId(project_id.toString())
project_id: ObjectId(project_id.toString()),
},
filter,
function (error, docs) {
@ -50,7 +50,7 @@ module.exports = MongoManager = {
getArchivedProjectDocs(project_id, callback) {
const query = {
project_id: ObjectId(project_id.toString()),
inS3: true
inS3: true,
}
return db.docs.find(query, {}, callback)
},
@ -59,11 +59,11 @@ module.exports = MongoManager = {
const update = {
$set: updates,
$inc: {
rev: 1
rev: 1,
},
$unset: {
inS3: true
}
inS3: true,
},
}
update.$set.project_id = ObjectId(project_id)
return db.docs.update(
@ -78,10 +78,10 @@ module.exports = MongoManager = {
return db.docs.update(
{
_id: ObjectId(doc_id),
project_id: ObjectId(project_id)
project_id: ObjectId(project_id),
},
{
$set: { deleted: true }
$set: { deleted: true },
},
callback
)
@ -90,14 +90,14 @@ module.exports = MongoManager = {
markDocAsArchived(doc_id, rev, callback) {
const update = {
$set: {},
$unset: {}
$unset: {},
}
update.$set.inS3 = true
update.$unset.lines = true
update.$unset.ranges = true
const query = {
_id: doc_id,
rev
rev,
}
return db.docs.update(query, update, (err) => callback(err))
},
@ -108,10 +108,10 @@ module.exports = MongoManager = {
}
return db.docOps.find(
{
doc_id: ObjectId(doc_id)
doc_id: ObjectId(doc_id),
},
{
version: 1
version: 1,
},
function (error, docs) {
if (error != null) {
@ -132,13 +132,13 @@ module.exports = MongoManager = {
}
return db.docOps.update(
{
doc_id: ObjectId(doc_id)
doc_id: ObjectId(doc_id),
},
{
$set: { version }
$set: { version },
},
{
upsert: true
upsert: true,
},
callback
)
@ -147,7 +147,7 @@ module.exports = MongoManager = {
destroyDoc(doc_id, callback) {
return db.docs.remove(
{
_id: ObjectId(doc_id)
_id: ObjectId(doc_id),
},
function (err) {
if (err != null) {
@ -155,13 +155,13 @@ module.exports = MongoManager = {
}
return db.docOps.remove(
{
doc_id: ObjectId(doc_id)
doc_id: ObjectId(doc_id),
},
callback
)
}
)
}
},
}
const methods = Object.getOwnPropertyNames(MongoManager)

View file

@ -65,5 +65,5 @@ module.exports = RangeManager = {
} catch (error) {
return data
}
}
},
}

View file

@ -5,5 +5,5 @@ const mongojs = require('mongojs')
const db = mongojs(Settings.mongo.url, ['docs', 'docOps'])
module.exports = {
db,
ObjectId: mongojs.ObjectId
ObjectId: mongojs.ObjectId,
}

View file

@ -5,4 +5,4 @@ docstore
--env-pass-through=
--node-version=10.21.0
--public-repo=True
--script-version=3.2.0
--script-version=3.3.2

View file

@ -10,8 +10,8 @@ const Settings = {
internal: {
docstore: {
port: 3016,
host: process.env.LISTEN_ADDRESS || 'localhost'
}
host: process.env.LISTEN_ADDRESS || 'localhost',
},
},
mongo: {},
@ -19,17 +19,17 @@ const Settings = {
docstore: {
backend: process.env.BACKEND || 's3',
healthCheck: {
project_id: process.env.HEALTH_CHECK_PROJECT_ID
project_id: process.env.HEALTH_CHECK_PROJECT_ID,
},
bucket: process.env.BUCKET_NAME || process.env.AWS_BUCKET || 'bucket',
gcs: {
unlockBeforeDelete: process.env.GCS_UNLOCK_BEFORE_DELETE === 'true',
deletedBucketSuffix: process.env.GCS_DELETED_BUCKET_SUFFIX,
deleteConcurrency: parseInt(process.env.GCS_DELETE_CONCURRENCY) || 50
}
deleteConcurrency: parseInt(process.env.GCS_DELETE_CONCURRENCY) || 50,
},
},
max_doc_length: parseInt(process.env.MAX_DOC_LENGTH) || 2 * 1024 * 1024 // 2mb
max_doc_length: parseInt(process.env.MAX_DOC_LENGTH) || 2 * 1024 * 1024, // 2mb
}
if (process.env.MONGO_CONNECTION_STRING != null) {
@ -51,7 +51,7 @@ if (
bucket: process.env.AWS_BUCKET,
endpoint: process.env.AWS_S3_ENDPOINT,
pathStyle: process.env.AWS_S3_PATH_STYLE,
partSize: parseInt(process.env.AWS_S3_PARTSIZE) || 100 * 1024 * 1024
partSize: parseInt(process.env.AWS_S3_PARTSIZE) || 100 * 1024 * 1024,
}
}
@ -59,7 +59,7 @@ if (process.env.GCS_API_ENDPOINT) {
Settings.docstore.gcs.endpoint = {
apiEndpoint: process.env.GCS_API_ENDPOINT,
apiScheme: process.env.GCS_API_SCHEME,
projectId: process.env.GCS_PROJECT_ID
projectId: process.env.GCS_PROJECT_ID,
}
}
@ -69,7 +69,7 @@ if (process.env.FALLBACK_BACKEND) {
// mapping of bucket names on the fallback, to bucket names on the primary.
// e.g. { myS3UserFilesBucketName: 'myGoogleUserFilesBucketName' }
buckets: JSON.parse(process.env.FALLBACK_BUCKET_MAPPING || '{}'),
copyOnMiss: process.env.COPY_ON_MISS === 'true'
copyOnMiss: process.env.COPY_ON_MISS === 'true',
}
}

View file

@ -49,7 +49,7 @@ services:
command: tar -czf /tmp/build/build.tar.gz --exclude=build.tar.gz --exclude-vcs .
user: root
mongo:
image: mongo:3.6
image: mongo:4.0
gcs:
build:
context: test/acceptance/deps

View file

@ -47,7 +47,7 @@ services:
command: npm run --silent test:acceptance
mongo:
image: mongo:3.6
image: mongo:4.0
gcs:
build:

View file

@ -993,9 +993,9 @@
}
},
"@grpc/proto-loader": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.5.4.tgz",
"integrity": "sha512-HTM4QpI9B2XFkPz7pjwMyMgZchJ93TVkL3kWPW8GDMDKYxsMnmf4w2TNMJK7+KNiYHS5cJrCEAFlF+AwtXWVPA==",
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.5.5.tgz",
"integrity": "sha512-WwN9jVNdHRQoOBo9FDH7qU+mgfjPc8GygPYms3M+y3fbQLfnCe/Kv/E01t7JRgnrsOHH8euvSbed3mIalXhwqQ==",
"requires": {
"lodash.camelcase": "^4.3.0",
"protobufjs": "^6.8.6"
@ -1760,7 +1760,6 @@
"version": "1.8.14",
"resolved": "https://registry.npmjs.org/bunyan/-/bunyan-1.8.14.tgz",
"integrity": "sha512-LlahJUxXzZLuw/hetUQJmRgZ1LF6+cr5TPpRj6jf327AsiIq2jhYEH4oqUUkVKTor+9w2BT3oxVwhzE5lw9tcg==",
"dev": true,
"requires": {
"dtrace-provider": "~0.8",
"moment": "^2.19.3",
@ -1869,7 +1868,7 @@
"charenc": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
"integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA=="
"integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc="
},
"check-error": {
"version": "1.0.2",
@ -2155,7 +2154,7 @@
"crypt": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
"integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow=="
"integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs="
},
"crypto-random-string": {
"version": "2.0.0",
@ -2165,7 +2164,7 @@
"d64": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/d64/-/d64-1.0.0.tgz",
"integrity": "sha512-5eNy3WZziVYnrogqgXhcdEmqcDB2IHurTqLcrgssJsfkMVCUoUaZpK6cJjxxvLV2dUm5SuJMNcYfVGoin9UIRw=="
"integrity": "sha1-QAKofoUMv8n52XBrYPymE6MzbpA="
},
"damerau-levenshtein": {
"version": "1.0.6",
@ -2584,12 +2583,6 @@
"integrity": "sha512-ExTJKhgeYMfY8wDj3UiZmgpMKJOUHGNHmWMlxT49JUDB1vTnw0sSNfXJSxnX+LcebyBD/gudXzjzD136WqPJrQ==",
"dev": true
},
"eslint-plugin-chai-friendly": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-chai-friendly/-/eslint-plugin-chai-friendly-0.6.0.tgz",
"integrity": "sha512-Uvvv1gkbRGp/qfN15B0kQyQWg+oFA8buDSqrwmW3egNSk/FpqH2MjQqKOuKwmEL6w4QIQrIjDp+gg6kGGmD3oQ==",
"dev": true
},
"eslint-plugin-es": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz",
@ -4292,12 +4285,12 @@
"lodash.at": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.at/-/lodash.at-4.6.0.tgz",
"integrity": "sha512-GOTh0SEp+Yosnlpjic+8cl2WM9MykorogkGA9xyIFkkObQ3H3kNZqZ+ohuq4K3FrSVo7hMcZBMataJemrxC3BA=="
"integrity": "sha1-k83OZk8KGZTqM9181A4jr9EbD/g="
},
"lodash.camelcase": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz",
"integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA=="
"integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY="
},
"lodash.flattendeep": {
"version": "4.4.0",
@ -4313,7 +4306,7 @@
"lodash.has": {
"version": "4.5.2",
"resolved": "https://registry.npmjs.org/lodash.has/-/lodash.has-4.5.2.tgz",
"integrity": "sha512-rnYUdIo6xRCJnQmbVFEwcxF144erlD+M3YcJUVesflU9paQaE8p+fJDcIQrlMYbxoANFL+AB9hZrzSBBk5PL+g=="
"integrity": "sha1-0Z9NwQlQWMzL4rDN9O4P5Ko3yGI="
},
"lodash.memoize": {
"version": "4.1.2",
@ -4353,28 +4346,16 @@
}
},
"logger-sharelatex": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/logger-sharelatex/-/logger-sharelatex-2.1.1.tgz",
"integrity": "sha512-qqSrBqUgHWnStxtTZ/fSsqPxj9Ju9onok7Vfm3bv5MS702jH+hRsCSA9oXOMvOLcWJrZFnhCZaLGeOvXToUaxw==",
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/logger-sharelatex/-/logger-sharelatex-2.2.0.tgz",
"integrity": "sha512-ko+OmE25XHJJCiz1R9EgwlfM7J/5olpunUfR3WcfuqOQrcUqsdBrDA2sOytngT0ViwjCR0Fh4qZVPwEWfmrvwA==",
"requires": {
"@google-cloud/logging-bunyan": "^3.0.0",
"@overleaf/o-error": "^3.0.0",
"bunyan": "^1.8.14",
"node-fetch": "^2.6.0",
"raven": "^2.6.4",
"yn": "^4.0.0"
},
"dependencies": {
"bunyan": {
"version": "1.8.14",
"resolved": "https://registry.npmjs.org/bunyan/-/bunyan-1.8.14.tgz",
"integrity": "sha512-LlahJUxXzZLuw/hetUQJmRgZ1LF6+cr5TPpRj6jf327AsiIq2jhYEH4oqUUkVKTor+9w2BT3oxVwhzE5lw9tcg==",
"requires": {
"dtrace-provider": "~0.8",
"moment": "^2.19.3",
"mv": "~2",
"safe-json-stringify": "~1"
}
}
}
},
"loglevel": {
@ -4506,13 +4487,13 @@
"integrity": "sha512-glc9y00wgtwcDmp7GaE/0b0OnxpNJsVf3ael/An6Fe2Q51LLwN1er6sdomLRzz5h0+yMpiYLhWYF5R7HeqVd4g=="
},
"md5": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/md5/-/md5-2.2.1.tgz",
"integrity": "sha512-PlGG4z5mBANDGCKsYQe0CaUYHdZYZt8ZPZLmEt+Urf0W4GlpTX4HescwHU+dc9+Z/G/vZKYZYFrwgm9VxK6QOQ==",
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz",
"integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==",
"requires": {
"charenc": "~0.0.1",
"crypt": "~0.0.1",
"is-buffer": "~1.1.1"
"charenc": "0.0.2",
"crypt": "0.0.2",
"is-buffer": "~1.1.6"
},
"dependencies": {
"is-buffer": {
@ -6019,9 +6000,9 @@
}
},
"protobufjs": {
"version": "6.9.0",
"resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.9.0.tgz",
"integrity": "sha512-LlGVfEWDXoI/STstRDdZZKb/qusoAWUnmLg9R8OLSO473mBLWHowx8clbX5/+mKDEI+v7GzjoK9tRPZMMcoTrg==",
"version": "6.10.1",
"resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.1.tgz",
"integrity": "sha512-pb8kTchL+1Ceg4lFd5XUpK8PdWacbvV5SK2ULH2ebrYtl4GjJmS24m6CKME67jzV53tbJxHlnNOSqQHbTsR9JQ==",
"requires": {
"@protobufjs/aspromise": "^1.1.2",
"@protobufjs/base64": "^1.1.2",
@ -6147,12 +6128,12 @@
"cookie": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz",
"integrity": "sha512-+IJOX0OqlHCszo2mBUq+SrEbCj6w7Kpffqx60zYbPTFaO4+yYgRjHwcZNpWvaTylDHaV7PPmBHzSecZiMhtPgw=="
"integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s="
},
"stack-trace": {
"version": "0.0.10",
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
"integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg=="
"integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA="
},
"uuid": {
"version": "3.3.2",
@ -7163,7 +7144,7 @@
"timed-out": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz",
"integrity": "sha512-G7r3AhovYtr5YKOWQkta8RKAPb+J9IsO4uVmzjl8AZwfhs8UcUwTiD6gcJYSgOtzyjvQKrKYn41syHbUWMkafA=="
"integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8="
},
"tiny-async-pool": {
"version": "1.1.0",
@ -7196,7 +7177,7 @@
"to-no-case": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/to-no-case/-/to-no-case-1.0.2.tgz",
"integrity": "sha512-Z3g735FxuZY8rodxV4gH7LxClE4H0hTIyHNIHdk+vpQxjLm0cwnKXq/OFVZ76SOQmto7txVcwSCwkU5kqp+FKg=="
"integrity": "sha1-xyKQcWTvaxeBMsjmmTAhLRtKoWo="
},
"to-regex-range": {
"version": "5.0.1",
@ -7210,7 +7191,7 @@
"to-snake-case": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/to-snake-case/-/to-snake-case-1.0.0.tgz",
"integrity": "sha512-joRpzBAk1Bhi2eGEYBjukEWHOe/IvclOkiJl3DtA91jV6NwQ3MwXA4FHYeqk8BNp/D8bmi9tcNbRu/SozP0jbQ==",
"integrity": "sha1-znRpE4l5RgGah+Yu366upMYIq4w=",
"requires": {
"to-space-case": "^1.0.0"
}
@ -7218,7 +7199,7 @@
"to-space-case": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/to-space-case/-/to-space-case-1.0.0.tgz",
"integrity": "sha512-rLdvwXZ39VOn1IxGL3V6ZstoTbwLRckQmn/U8ZDLuWwIXNpuZDhQ3AiRUlhTbOXFVE9C+dR51wM0CBDhk31VcA==",
"integrity": "sha1-sFLar7Gysp3HcM6gFj5ewOvJ/Bc=",
"requires": {
"to-no-case": "^1.0.0"
}

View file

@ -23,7 +23,7 @@
"async": "^2.6.3",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"logger-sharelatex": "^2.1.1",
"logger-sharelatex": "^2.2.0",
"metrics-sharelatex": "^2.7.0",
"mongojs": "3.1.0",
"settings-sharelatex": "^1.1.0",
@ -38,22 +38,22 @@
"chai": "~4.2.0",
"chai-as-promised": "^7.1.1",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.11.0",
"eslint-config-standard": "^14.1.1",
"eslint-config-prettier": "^6.10.0",
"eslint-config-standard": "^14.1.0",
"eslint-config-standard-jsx": "^8.1.0",
"eslint-config-standard-react": "^9.2.0",
"eslint-plugin-chai-expect": "^2.2.0",
"eslint-plugin-chai-friendly": "^0.6.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-chai-expect": "^2.1.0",
"eslint-plugin-chai-friendly": "^0.5.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-mocha": "^6.3.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-standard": "^4.0.1",
"mocha": "^7.2.0",
"prettier": "^2.0.5",
"prettier": "^2.0.0",
"prettier-eslint-cli": "^5.0.0",
"request": "~2.88.2",
"sandboxed-module": "~2.0.4",

View file

@ -51,14 +51,14 @@ describe('Archiving', function () {
_id: ObjectId(),
lines: ['one', 'two', 'three'],
ranges: {},
version: 2
version: 2,
},
{
_id: ObjectId(),
lines: ['aaa', 'bbb', 'ccc'],
ranges: {},
version: 4
}
version: 4,
},
]
const jobs = Array.from(this.docs).map((doc) =>
((doc) => {
@ -173,7 +173,7 @@ describe('Archiving', function () {
_id: ObjectId(),
lines: ['one', 'two', 'three'],
ranges: {},
version: 2
version: 2,
}
return DocstoreClient.createDoc(
this.project_id,
@ -287,7 +287,7 @@ describe('Archiving', function () {
_id: ObjectId(),
lines: [big_line, big_line, big_line, big_line],
ranges: {},
version: 2
version: 2,
}
return DocstoreClient.createDoc(
this.project_id,
@ -758,10 +758,10 @@ describe('Archiving', function () {
'Roses are \u001b[0;31mred\u001b[0m, violets are \u001b[0;34mblue. Hope you enjoy terminal hue',
'But now...\u001b[20Cfor my greatest trick...\u001b[8m',
'The quic\b\b\b\b\b\bk brown fo\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007\u0007x... [Beeeep]',
'Powerلُلُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ冗'
'Powerلُلُصّبُلُلصّبُررً ॣ ॣh ॣ ॣ冗',
],
ranges: {},
version: 2
version: 2,
}
return DocstoreClient.createDoc(
this.project_id,
@ -857,17 +857,17 @@ describe('Archiving', function () {
op: { i: 'foo', p: 24 },
metadata: {
user_id: ObjectId(),
ts: new Date('2017-01-27T16:10:44.194Z')
}
ts: new Date('2017-01-27T16:10:44.194Z'),
},
},
{
id: ObjectId(),
op: { d: 'bar', p: 50 },
metadata: {
user_id: ObjectId(),
ts: new Date('2017-01-27T18:10:44.194Z')
}
}
ts: new Date('2017-01-27T18:10:44.194Z'),
},
},
],
comments: [
{
@ -875,12 +875,12 @@ describe('Archiving', function () {
op: { c: 'comment', p: 284, t: ObjectId() },
metadata: {
user_id: ObjectId(),
ts: new Date('2017-01-26T14:22:04.869Z')
}
}
]
ts: new Date('2017-01-26T14:22:04.869Z'),
},
version: 2
},
],
},
version: 2,
}
return DocstoreClient.createDoc(
this.project_id,
@ -971,7 +971,7 @@ describe('Archiving', function () {
_id: ObjectId(),
lines: ['abc', 'def', 'ghi'],
ranges: {},
version: 2
version: 2,
}
return DocstoreClient.createDoc(
this.project_id,
@ -1067,7 +1067,7 @@ describe('Archiving', function () {
_id: ObjectId(),
lines: ['abc', 'def', 'ghi'],
ranges: {},
version: 2
version: 2,
}
uploadContent(
`${this.project_id}/${this.doc._id}`,
@ -1079,7 +1079,7 @@ describe('Archiving', function () {
project_id: this.project_id,
_id: this.doc._id,
rev: this.doc.version,
inS3: true
inS3: true,
},
(error) => {
if (error != null) {

View file

@ -28,26 +28,26 @@ describe('Getting all docs', function () {
_id: ObjectId(),
lines: ['one', 'two', 'three'],
ranges: { mock: 'one' },
rev: 2
rev: 2,
},
{
_id: ObjectId(),
lines: ['aaa', 'bbb', 'ccc'],
ranges: { mock: 'two' },
rev: 4
rev: 4,
},
{
_id: ObjectId(),
lines: ['111', '222', '333'],
ranges: { mock: 'three' },
rev: 6
}
rev: 6,
},
]
this.deleted_doc = {
_id: ObjectId(),
lines: ['deleted'],
ranges: { mock: 'four' },
rev: 8
rev: 8,
}
const version = 42
const jobs = Array.from(this.docs).map((doc) =>

View file

@ -32,10 +32,10 @@ describe('Getting a doc', function () {
op: { i: 'foo', p: 3 },
meta: {
user_id: ObjectId().toString(),
ts: new Date().toString()
}
}
]
ts: new Date().toString(),
},
},
],
}
return DocstoreApp.ensureRunning(() => {
return DocstoreClient.createDoc(

View file

@ -31,10 +31,10 @@ describe('Applying updates to a doc', function () {
op: { i: 'foo', p: 3 },
meta: {
user_id: ObjectId().toString(),
ts: new Date().toString()
}
}
]
ts: new Date().toString(),
},
},
],
}
this.newRanges = {
changes: [
@ -43,10 +43,10 @@ describe('Applying updates to a doc', function () {
op: { i: 'bar', p: 6 },
meta: {
user_id: ObjectId().toString(),
ts: new Date().toString()
}
}
]
ts: new Date().toString(),
},
},
],
}
this.version = 42
return DocstoreApp.ensureRunning(() => {

View file

@ -48,5 +48,5 @@ module.exports = {
}
)
}
}
},
}

View file

@ -54,7 +54,7 @@ module.exports = DocstoreClient = {
{
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}`,
json: true,
qs
qs,
},
callback
)
@ -67,7 +67,7 @@ module.exports = DocstoreClient = {
return request.get(
{
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc`,
json: true
json: true,
},
(req, res, body) => {
callback(req, res, body)
@ -82,7 +82,7 @@ module.exports = DocstoreClient = {
return request.get(
{
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/ranges`,
json: true
json: true,
},
callback
)
@ -98,8 +98,8 @@ module.exports = DocstoreClient = {
json: {
lines,
version,
ranges
}
ranges,
},
},
callback
)
@ -111,7 +111,7 @@ module.exports = DocstoreClient = {
}
return request.del(
{
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}`
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}`,
},
callback
)
@ -123,7 +123,7 @@ module.exports = DocstoreClient = {
}
return request.post(
{
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/archive`
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/archive`,
},
callback
)
@ -135,7 +135,7 @@ module.exports = DocstoreClient = {
}
return request.post(
{
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/destroy`
url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/destroy`,
},
callback
)
@ -151,5 +151,5 @@ module.exports = DocstoreClient = {
callback(null, JSON.parse(data))
})
.catch(callback)
}
},
}

View file

@ -32,24 +32,24 @@ describe('DocArchiveManager', function () {
md5Sum = 'decafbad'
RangeManager = {
jsonRangesToMongo: sinon.stub().returns({ mongo: 'ranges' })
jsonRangesToMongo: sinon.stub().returns({ mongo: 'ranges' }),
}
Settings = {
docstore: {
bucket: 'wombat'
}
bucket: 'wombat',
},
}
Logger = {
log: sinon.stub(),
err: sinon.stub()
err: sinon.stub(),
}
HashDigest = sinon.stub().returns(md5Sum)
HashUpdate = sinon.stub().returns({ digest: HashDigest })
Crypto = {
createHash: sinon.stub().returns({ update: HashUpdate })
createHash: sinon.stub().returns({ update: HashUpdate }),
}
Streamifier = {
createReadStream: sinon.stub().returns({ stream: 'readStream' })
createReadStream: sinon.stub().returns({ stream: 'readStream' }),
}
projectId = ObjectId()
@ -57,69 +57,69 @@ describe('DocArchiveManager', function () {
{
_id: ObjectId(),
inS3: true,
rev: 2
rev: 2,
},
{
_id: ObjectId(),
inS3: true,
rev: 4
rev: 4,
},
{
_id: ObjectId(),
inS3: true,
rev: 6
}
rev: 6,
},
]
mongoDocs = [
{
_id: ObjectId(),
lines: ['one', 'two', 'three'],
rev: 2
rev: 2,
},
{
_id: ObjectId(),
lines: ['aaa', 'bbb', 'ccc'],
rev: 4
rev: 4,
},
{
_id: ObjectId(),
inS3: true,
rev: 6
rev: 6,
},
{
_id: ObjectId(),
inS3: true,
rev: 6
rev: 6,
},
{
_id: ObjectId(),
lines: ['111', '222', '333'],
rev: 6
}
rev: 6,
},
]
docJson = JSON.stringify({
lines: mongoDocs[0].lines,
ranges: mongoDocs[0].ranges,
schema_v: 1
schema_v: 1,
})
stream = {
on: sinon.stub(),
resume: sinon.stub()
resume: sinon.stub(),
}
stream.on.withArgs('data').yields(Buffer.from(docJson, 'utf8'))
stream.on.withArgs('end').yields()
readStream = {
stream: 'readStream'
stream: 'readStream',
}
PersistorManager = {
getObjectStream: sinon.stub().resolves(stream),
sendStream: sinon.stub().resolves(),
getObjectMd5Hash: sinon.stub().resolves(md5Sum),
deleteObject: sinon.stub().resolves()
deleteObject: sinon.stub().resolves(),
}
MongoManager = {
@ -129,8 +129,8 @@ describe('DocArchiveManager', function () {
getProjectsDocs: sinon.stub().resolves(mongoDocs),
getArchivedProjectDocs: sinon.stub().resolves(archivedDocs),
findDoc: sinon.stub().resolves(),
destroyDoc: sinon.stub().resolves()
}
destroyDoc: sinon.stub().resolves(),
},
}
for (const mongoDoc of mongoDocs) {
MongoManager.promises.findDoc
@ -147,12 +147,12 @@ describe('DocArchiveManager', function () {
'./MongoManager': MongoManager,
'./RangeManager': RangeManager,
'./PersistorManager': PersistorManager,
'./Errors': Errors
'./Errors': Errors,
},
globals: {
console,
JSON
}
JSON,
},
})
})
@ -183,7 +183,7 @@ describe('DocArchiveManager', function () {
const json = JSON.stringify({
lines: mongoDocs[0].lines,
ranges: mongoDocs[0].ranges,
schema_v: 1
schema_v: 1,
})
await DocArchiveManager.promises.archiveDoc(projectId, mongoDocs[0])
@ -290,7 +290,7 @@ describe('DocArchiveManager', function () {
describe('when the doc has the old schema', function () {
beforeEach(function () {
mongoDoc = {
lines: ['doc', 'lines']
lines: ['doc', 'lines'],
}
s3Doc = ['doc', 'lines']
docJson = JSON.stringify(s3Doc)
@ -310,11 +310,11 @@ describe('DocArchiveManager', function () {
s3Doc = {
lines: ['doc', 'lines'],
ranges: { json: 'ranges' },
schema_v: 1
schema_v: 1,
}
mongoDoc = {
lines: ['doc', 'lines'],
ranges: { mongo: 'ranges' }
ranges: { mongo: 'ranges' },
}
docJson = JSON.stringify(s3Doc)
stream.on.withArgs('data').yields(Buffer.from(docJson, 'utf8'))
@ -332,10 +332,10 @@ describe('DocArchiveManager', function () {
beforeEach(function () {
s3Doc = {
lines: ['doc', 'lines'],
schema_v: 1
schema_v: 1,
}
mongoDoc = {
lines: ['doc', 'lines']
lines: ['doc', 'lines'],
}
docJson = JSON.stringify(s3Doc)
stream.on.withArgs('data').yields(Buffer.from(docJson, 'utf8'))
@ -353,7 +353,7 @@ describe('DocArchiveManager', function () {
beforeEach(function () {
s3Doc = {
lines: ['doc', 'lines'],
schema_v: 2
schema_v: 2,
}
docJson = JSON.stringify(s3Doc)
stream.on.withArgs('data').yields(Buffer.from(docJson, 'utf8'))

View file

@ -32,15 +32,15 @@ describe('DocManager', function () {
jsonRangesToMongo(r) {
return r
},
shouldUpdateRanges: sinon.stub().returns(false)
shouldUpdateRanges: sinon.stub().returns(false),
}),
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
warn() {},
err() {}
err() {},
}),
'./Errors': Errors
}
'./Errors': Errors,
},
})
this.doc_id = ObjectId().toString()
this.project_id = ObjectId().toString()
@ -99,7 +99,7 @@ describe('DocManager', function () {
this.DocManager._getDoc = sinon.stub()
return (this.doc = {
_id: this.doc_id,
lines: ['2134']
lines: ['2134'],
})
})
@ -117,7 +117,7 @@ describe('DocManager', function () {
deleted: true,
version: true,
ranges: true,
inS3: true
inS3: true,
})
.should.equal(true)
return done()
@ -154,7 +154,7 @@ describe('DocManager', function () {
this.DocManager._getDoc
.calledWith(this.project_id, this.doc_id, {
lines: true,
inS3: true
inS3: true,
})
.should.equal(true)
return done()
@ -181,7 +181,7 @@ describe('DocManager', function () {
this.doc = {
_id: this.doc_id,
project_id: this.project_id,
lines: ['mock-lines']
lines: ['mock-lines'],
}
this.version = 42
this.MongoManager.findDoc = sinon.stub()
@ -302,7 +302,7 @@ describe('DocManager', function () {
_id: this.doc_id,
project_id: this.project_id,
lines: ['mock-lines'],
inS3: true
inS3: true,
}
this.MongoManager.findDoc.yields(null, this.doc)
this.DocArchiveManager.unarchiveDoc = (
@ -368,8 +368,8 @@ describe('DocManager', function () {
{
_id: this.doc_id,
project_id: this.project_id,
lines: ['mock-lines']
}
lines: ['mock-lines'],
},
]
this.MongoManager.getProjectsDocs = sinon
.stub()
@ -490,10 +490,10 @@ describe('DocManager', function () {
op: { i: 'foo', p: 3 },
meta: {
user_id: ObjectId().toString(),
ts: new Date().toString()
}
}
]
ts: new Date().toString(),
},
},
],
}
this.newRanges = {
changes: [
@ -502,10 +502,10 @@ describe('DocManager', function () {
op: { i: 'bar', p: 6 },
meta: {
user_id: ObjectId().toString(),
ts: new Date().toString()
}
}
]
ts: new Date().toString(),
},
},
],
}
this.version = 42
this.doc = {
@ -514,7 +514,7 @@ describe('DocManager', function () {
lines: this.oldDocLines,
rev: (this.rev = 5),
version: this.version,
ranges: this.originalRanges
ranges: this.originalRanges,
}
this.MongoManager.upsertIntoDocCollection = sinon.stub().callsArg(3)
@ -543,7 +543,7 @@ describe('DocManager', function () {
lines: true,
version: true,
ranges: true,
inS3: true
inS3: true,
})
.should.equal(true)
})
@ -789,7 +789,7 @@ describe('DocManager', function () {
return this.MongoManager.upsertIntoDocCollection
.calledWith(this.project_id, this.doc_id, {
lines: this.newDocLines,
ranges: this.originalRanges
ranges: this.originalRanges,
})
.should.equal(true)
})

View file

@ -29,17 +29,17 @@ describe('HttpController', function () {
'./DocArchiveManager': (this.DocArchiveManager = {}),
'logger-sharelatex': (this.logger = {
log: sinon.stub(),
error: sinon.stub()
error: sinon.stub(),
}),
'./HealthChecker': {}
'./HealthChecker': {},
},
globals: { process }
globals: { process },
})
this.res = {
send: sinon.stub(),
sendStatus: sinon.stub(),
json: sinon.stub(),
setHeader: sinon.stub()
setHeader: sinon.stub(),
}
this.res.status = sinon.stub().returns(this.res)
this.req = { query: {} }
@ -50,14 +50,14 @@ describe('HttpController', function () {
_id: this.doc_id,
lines: ['mock', 'lines', ' here', '', '', ' spaces '],
version: 42,
rev: 5
rev: 5,
}
return (this.deletedDoc = {
deleted: true,
_id: this.doc_id,
lines: ['mock', 'lines', ' here', '', '', ' spaces '],
version: 42,
rev: 5
rev: 5,
})
})
@ -66,7 +66,7 @@ describe('HttpController', function () {
beforeEach(function () {
this.req.params = {
project_id: this.project_id,
doc_id: this.doc_id
doc_id: this.doc_id,
}
this.DocManager.getFullDoc = sinon
.stub()
@ -86,7 +86,7 @@ describe('HttpController', function () {
_id: this.doc_id,
lines: this.doc.lines,
rev: this.doc.rev,
version: this.doc.version
version: this.doc.version,
})
.should.equal(true)
})
@ -96,7 +96,7 @@ describe('HttpController', function () {
beforeEach(function () {
this.req.params = {
project_id: this.project_id,
doc_id: this.doc_id
doc_id: this.doc_id,
}
return (this.DocManager.getFullDoc = sinon
.stub()
@ -124,7 +124,7 @@ describe('HttpController', function () {
lines: this.doc.lines,
rev: this.doc.rev,
deleted: true,
version: this.doc.version
version: this.doc.version,
})
.should.equal(true)
})
@ -135,7 +135,7 @@ describe('HttpController', function () {
beforeEach(function () {
this.req.params = {
project_id: this.project_id,
doc_id: this.doc_id
doc_id: this.doc_id,
}
this.DocManager.getDocLines = sinon.stub().callsArgWith(2, null, this.doc)
return this.HttpController.getRawDoc(this.req, this.res, this.next)
@ -169,13 +169,13 @@ describe('HttpController', function () {
{
_id: ObjectId(),
lines: ['mock', 'lines', 'one'],
rev: 2
rev: 2,
},
{
_id: ObjectId(),
lines: ['mock', 'lines', 'two'],
rev: 4
}
rev: 4,
},
]
this.DocManager.getAllNonDeletedDocs = sinon
.stub()
@ -195,13 +195,13 @@ describe('HttpController', function () {
{
_id: this.docs[0]._id.toString(),
lines: this.docs[0].lines,
rev: this.docs[0].rev
rev: this.docs[0].rev,
},
{
_id: this.docs[1]._id.toString(),
lines: this.docs[1].lines,
rev: this.docs[1].rev
}
rev: this.docs[1].rev,
},
])
.should.equal(true)
})
@ -214,14 +214,14 @@ describe('HttpController', function () {
{
_id: ObjectId(),
lines: ['mock', 'lines', 'one'],
rev: 2
rev: 2,
},
null,
{
_id: ObjectId(),
lines: ['mock', 'lines', 'two'],
rev: 4
}
rev: 4,
},
]
this.DocManager.getAllNonDeletedDocs = sinon
.stub()
@ -235,13 +235,13 @@ describe('HttpController', function () {
{
_id: this.docs[0]._id.toString(),
lines: this.docs[0].lines,
rev: this.docs[0].rev
rev: this.docs[0].rev,
},
{
_id: this.docs[2]._id.toString(),
lines: this.docs[2].lines,
rev: this.docs[2].rev
}
rev: this.docs[2].rev,
},
])
.should.equal(true)
})
@ -251,7 +251,7 @@ describe('HttpController', function () {
.calledWith(
{
err: sinon.match.has('message', 'null doc'),
project_id: this.project_id
project_id: this.project_id,
},
'encountered null doc'
)
@ -267,12 +267,12 @@ describe('HttpController', function () {
this.docs = [
{
_id: ObjectId(),
ranges: { mock_ranges: 'one' }
ranges: { mock_ranges: 'one' },
},
{
_id: ObjectId(),
ranges: { mock_ranges: 'two' }
}
ranges: { mock_ranges: 'two' },
},
]
this.DocManager.getAllNonDeletedDocs = sinon
.stub()
@ -291,12 +291,12 @@ describe('HttpController', function () {
.calledWith([
{
_id: this.docs[0]._id.toString(),
ranges: this.docs[0].ranges
ranges: this.docs[0].ranges,
},
{
_id: this.docs[1]._id.toString(),
ranges: this.docs[1].ranges
}
ranges: this.docs[1].ranges,
},
])
.should.equal(true)
})
@ -307,7 +307,7 @@ describe('HttpController', function () {
beforeEach(function () {
return (this.req.params = {
project_id: this.project_id,
doc_id: this.doc_id
doc_id: this.doc_id,
})
})
@ -316,7 +316,7 @@ describe('HttpController', function () {
this.req.body = {
lines: (this.lines = ['hello', 'world']),
version: (this.version = 42),
ranges: (this.ranges = { changes: 'mock' })
ranges: (this.ranges = { changes: 'mock' }),
}
this.DocManager.updateDoc = sinon
.stub()
@ -348,7 +348,7 @@ describe('HttpController', function () {
this.req.body = {
lines: (this.lines = ['hello', 'world']),
version: (this.version = 42),
ranges: {}
ranges: {},
}
this.DocManager.updateDoc = sinon
.stub()
@ -416,7 +416,7 @@ describe('HttpController', function () {
this.req.body = {
lines: (this.lines = Array(2049).fill('a'.repeat(1024))),
version: (this.version = 42),
ranges: (this.ranges = { changes: 'mock' })
ranges: (this.ranges = { changes: 'mock' }),
}
return this.HttpController.updateDoc(this.req, this.res, this.next)
})
@ -435,7 +435,7 @@ describe('HttpController', function () {
beforeEach(function () {
this.req.params = {
project_id: this.project_id,
doc_id: this.doc_id
doc_id: this.doc_id,
}
this.DocManager.deleteDoc = sinon.stub().callsArg(2)
return this.HttpController.deleteDoc(this.req, this.res, this.next)

View file

@ -25,14 +25,14 @@ describe('MongoManager', function () {
requires: {
'./mongojs': {
db: (this.db = { docs: {}, docOps: {} }),
ObjectId
ObjectId,
},
'metrics-sharelatex': { timeAsyncMethod: sinon.stub() },
'logger-sharelatex': { log() {} }
'logger-sharelatex': { log() {} },
},
globals: {
console
}
console,
},
})
this.project_id = ObjectId().toString()
this.doc_id = ObjectId().toString()
@ -58,7 +58,7 @@ describe('MongoManager', function () {
.calledWith(
{
_id: ObjectId(this.doc_id),
project_id: ObjectId(this.project_id)
project_id: ObjectId(this.project_id),
},
this.filter
)
@ -97,7 +97,7 @@ describe('MongoManager', function () {
.calledWith(
{
project_id: ObjectId(this.project_id),
deleted: { $ne: true }
deleted: { $ne: true },
},
this.filter
)
@ -125,7 +125,7 @@ describe('MongoManager', function () {
return this.db.docs.find
.calledWith(
{
project_id: ObjectId(this.project_id)
project_id: ObjectId(this.project_id),
},
this.filter
)
@ -189,7 +189,7 @@ describe('MongoManager', function () {
const args = this.db.docs.update.args[0]
assert.deepEqual(args[0], {
_id: ObjectId(this.doc_id),
project_id: ObjectId(this.project_id)
project_id: ObjectId(this.project_id),
})
assert.equal(args[1].$set.deleted, true)
return done()
@ -218,13 +218,13 @@ describe('MongoManager', function () {
it('should destroy the doc', function () {
return sinon.assert.calledWith(this.db.docs.remove, {
_id: ObjectId('123456789012')
_id: ObjectId('123456789012'),
})
})
return it('should destroy the docOps', function () {
return sinon.assert.calledWith(this.db.docOps.remove, {
doc_id: ObjectId('123456789012')
doc_id: ObjectId('123456789012'),
})
})
})
@ -275,15 +275,15 @@ describe('MongoManager', function () {
return this.db.docOps.update
.calledWith(
{
doc_id: ObjectId(this.doc_id)
doc_id: ObjectId(this.doc_id),
},
{
$set: {
version: this.version
}
version: this.version,
},
},
{
upsert: true
upsert: true,
}
)
.should.equal(true)

View file

@ -27,9 +27,9 @@ describe('RangeManager', function () {
return (this.RangeManager = SandboxedModule.require(modulePath, {
requires: {
'./mongojs': {
ObjectId
}
}
ObjectId,
},
},
}))
})
@ -47,16 +47,16 @@ describe('RangeManager', function () {
op: { i: 'foo', p: 3 },
metadata: {
user_id,
ts
}
}
ts,
},
},
],
comments: [
{
id: comment_id,
op: { c: 'foo', p: 3, t: thread_id }
}
]
op: { c: 'foo', p: 3, t: thread_id },
},
],
}).should.deep.equal({
changes: [
{
@ -64,16 +64,16 @@ describe('RangeManager', function () {
op: { i: 'foo', p: 3 },
metadata: {
user_id: ObjectId(user_id),
ts: new Date(ts)
}
}
ts: new Date(ts),
},
},
],
comments: [
{
id: ObjectId(comment_id),
op: { c: 'foo', p: 3, t: ObjectId(thread_id) }
}
]
op: { c: 'foo', p: 3, t: ObjectId(thread_id) },
},
],
})
})
@ -86,29 +86,29 @@ describe('RangeManager', function () {
{
id: change_id,
metadata: {
user_id
}
}
user_id,
},
},
],
comments: [
{
id: comment_id
}
]
id: comment_id,
},
],
}).should.deep.equal({
changes: [
{
id: change_id,
metadata: {
user_id
}
}
user_id,
},
},
],
comments: [
{
id: comment_id
}
]
id: comment_id,
},
],
})
})
@ -125,16 +125,16 @@ describe('RangeManager', function () {
op: { i: 'foo', p: 3 },
metadata: {
user_id,
ts
}
}
ts,
},
},
],
comments: [
{
id: comment_id,
op: { c: 'foo', p: 3, t: thread_id }
}
]
op: { c: 'foo', p: 3, t: thread_id },
},
],
}
const ranges1_copy = JSON.parse(JSON.stringify(ranges1)) // jsonRangesToMongo modifies in place
const ranges2 = JSON.parse(
@ -153,16 +153,16 @@ describe('RangeManager', function () {
op: { i: 'foo', p: 3 },
metadata: {
user_id: ObjectId(),
ts: new Date()
}
}
ts: new Date(),
},
},
],
comments: [
{
id: ObjectId(),
op: { c: 'foo', p: 3, t: ObjectId() }
}
]
op: { c: 'foo', p: 3, t: ObjectId() },
},
],
}
return (this.ranges_copy = this.RangeManager.jsonRangesToMongo(
JSON.parse(JSON.stringify(this.ranges))