[misc] bump the dev-env to 3.3.2

This commit is contained in:
Jakob Ackermann 2020-08-10 17:01:12 +01:00
parent de81ab2f70
commit f0551307d2
28 changed files with 383 additions and 497 deletions

View file

@ -0,0 +1,17 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
pull-request-branch-name:
# Separate sections of the branch name with a hyphen
# Docker images use the branch name and do not support slashes in tags
# https://github.com/overleaf/google-ops/issues/822
# https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#pull-request-branch-nameseparator
separator: "-"
# Block informal upgrades -- security upgrades use a separate queue.
# https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#open-pull-requests-limit
open-pull-requests-limit: 0

View file

@ -49,3 +49,6 @@ template_files/*
/log.json
hash_folder
# managed by dev-environment$ bin/update_build_scripts
.npmrc

View file

@ -17,8 +17,6 @@ RUN npm ci --quiet
COPY . /app
FROM base
COPY --from=app /app /app

View file

@ -1,131 +0,0 @@
String cron_string = BRANCH_NAME == "master" ? "@daily" : ""
pipeline {
agent any
environment {
GIT_PROJECT = "filestore"
JENKINS_WORKFLOW = "filestore-sharelatex"
TARGET_URL = "${env.JENKINS_URL}blue/organizations/jenkins/${JENKINS_WORKFLOW}/detail/$BRANCH_NAME/$BUILD_NUMBER/pipeline"
GIT_API_URL = "https://api.github.com/repos/overleaf/${GIT_PROJECT}/statuses/$GIT_COMMIT"
}
triggers {
pollSCM('* * * * *')
cron(cron_string)
}
stages {
stage('Install') {
steps {
withCredentials([usernamePassword(credentialsId: 'GITHUB_INTEGRATION', usernameVariable: 'GH_AUTH_USERNAME', passwordVariable: 'GH_AUTH_PASSWORD')]) {
sh "curl $GIT_API_URL \
--data '{ \
\"state\" : \"pending\", \
\"target_url\": \"$TARGET_URL\", \
\"description\": \"Your build is underway\", \
\"context\": \"ci/jenkins\" }' \
-u $GH_AUTH_USERNAME:$GH_AUTH_PASSWORD"
}
}
}
stage('Build') {
steps {
sh 'make build'
}
}
stage('Linting') {
steps {
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make format'
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make lint'
}
}
stage('Unit Tests') {
steps {
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_unit'
}
}
stage('Acceptance Tests') {
steps {
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_acceptance'
}
}
stage('Package and docker push') {
steps {
sh 'echo ${BUILD_NUMBER} > build_number.txt'
sh 'touch build.tar.gz' // Avoid tar warning about files changing during read
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make tar'
withCredentials([file(credentialsId: 'gcr.io_overleaf-ops', variable: 'DOCKER_REPO_KEY_PATH')]) {
sh 'docker login -u _json_key --password-stdin https://gcr.io/overleaf-ops < ${DOCKER_REPO_KEY_PATH}'
}
sh 'DOCKER_REPO=gcr.io/overleaf-ops make publish'
sh 'docker logout https://gcr.io/overleaf-ops'
}
}
stage('Publish to s3') {
steps {
sh 'echo ${BRANCH_NAME}-${BUILD_NUMBER} > build_number.txt'
withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") {
s3Upload(file:'build.tar.gz', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/${BUILD_NUMBER}.tar.gz")
}
withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") {
// The deployment process uses this file to figure out the latest build
s3Upload(file:'build_number.txt', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/latest")
}
}
}
}
post {
always {
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_clean'
sh 'make clean'
}
success {
withCredentials([usernamePassword(credentialsId: 'GITHUB_INTEGRATION', usernameVariable: 'GH_AUTH_USERNAME', passwordVariable: 'GH_AUTH_PASSWORD')]) {
sh "curl $GIT_API_URL \
--data '{ \
\"state\" : \"success\", \
\"target_url\": \"$TARGET_URL\", \
\"description\": \"Your build succeeded!\", \
\"context\": \"ci/jenkins\" }' \
-u $GH_AUTH_USERNAME:$GH_AUTH_PASSWORD"
}
}
failure {
mail(from: "${EMAIL_ALERT_FROM}",
to: "${EMAIL_ALERT_TO}",
subject: "Jenkins build failed: ${JOB_NAME}:${BUILD_NUMBER}",
body: "Build: ${BUILD_URL}")
withCredentials([usernamePassword(credentialsId: 'GITHUB_INTEGRATION', usernameVariable: 'GH_AUTH_USERNAME', passwordVariable: 'GH_AUTH_PASSWORD')]) {
sh "curl $GIT_API_URL \
--data '{ \
\"state\" : \"failure\", \
\"target_url\": \"$TARGET_URL\", \
\"description\": \"Your build failed\", \
\"context\": \"ci/jenkins\" }' \
-u $GH_AUTH_USERNAME:$GH_AUTH_PASSWORD"
}
}
}
// The options directive is for configuration that applies to the whole job.
options {
// we'd like to make sure remove old builds, so we don't fill up our storage!
buildDiscarder(logRotator(numToKeepStr:'50'))
// And we'd really like to be sure that this build doesn't hang forever, so let's time it out after:
timeout(time: 30, unit: 'MINUTES')
}
}

View file

@ -25,13 +25,13 @@ clean:
docker rmi gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
format:
$(DOCKER_COMPOSE) run --rm test_unit npm run format
$(DOCKER_COMPOSE) run --rm test_unit npm run --silent format
format_fix:
$(DOCKER_COMPOSE) run --rm test_unit npm run format:fix
$(DOCKER_COMPOSE) run --rm test_unit npm run --silent format:fix
lint:
$(DOCKER_COMPOSE) run --rm test_unit npm run lint
$(DOCKER_COMPOSE) run --rm test_unit npm run --silent lint
test: format lint test_unit test_acceptance

View file

@ -140,7 +140,7 @@ const host = '0.0.0.0'
if (!module.parent) {
// Called directly
app.listen(port, host, error => {
app.listen(port, host, (error) => {
if (error) {
logger.error('Error starting Filestore', error)
throw error
@ -153,7 +153,7 @@ process
.on('unhandledRejection', (reason, p) => {
logger.err(reason, 'Unhandled Rejection at Promise', p)
})
.on('uncaughtException', err => {
.on('uncaughtException', (err) => {
logger.err(err, 'Uncaught Exception thrown')
process.exit(1)
})

View file

@ -70,7 +70,7 @@ function getFile(req, res, next) {
return res.sendStatus(200).end()
}
pipeline(fileStream, res, err => {
pipeline(fileStream, res, (err) => {
if (err && err.code === 'ERR_STREAM_PREMATURE_CLOSE') {
res.end()
} else if (err) {
@ -140,7 +140,7 @@ function copyFile(req, res, next) {
PersistorManager.copyObject(bucket, `${oldProjectId}/${oldFileId}`, key)
.then(() => res.sendStatus(200))
.catch(err => {
.catch((err) => {
if (err) {
if (err instanceof Errors.NotFoundError) {
res.sendStatus(404)

View file

@ -62,7 +62,7 @@ module.exports = {
check(req, res, next) {
Promise.all([checkCanGetFiles(), checkFileConvert()])
.then(() => res.sendStatus(200))
.catch(err => {
.catch((err) => {
next(err)
})
}

View file

@ -38,10 +38,7 @@ class RequestLogger {
metrics.timing('http_request', responseTime, null, {
method: req.method,
status_code: res.statusCode,
path: routePath
.replace(/\//g, '_')
.replace(/:/g, '')
.slice(1)
path: routePath.replace(/\//g, '_').replace(/:/g, '').slice(1)
})
}

View file

@ -62,13 +62,13 @@ function safeExec(command, options, callback) {
cleanup()
})
child.on('error', err => {
child.on('error', (err) => {
cleanup(err)
})
child.stdout.on('data', chunk => {
child.stdout.on('data', (chunk) => {
stdout += chunk
})
child.stderr.on('data', chunk => {
child.stderr.on('data', (chunk) => {
stderr += chunk
})
}

View file

@ -1,11 +1,9 @@
filestore
--acceptance-creds=
--data-dirs=uploads,user_files,template_files
--dependencies=s3,gcs
--docker-repos=gcr.io/overleaf-ops
--env-add=ENABLE_CONVERSIONS="true",USE_PROM_METRICS="true",AWS_S3_USER_FILES_BUCKET_NAME=fake_user_files,AWS_S3_TEMPLATE_FILES_BUCKET_NAME=fake_template_files,AWS_S3_PUBLIC_FILES_BUCKET_NAME=fake_public_files
--env-pass-through=
--language=es
--node-version=12.18.0
--public-repo=True
--script-version=2.2.0
--script-version=3.3.2

View file

@ -11,6 +11,7 @@ services:
command: npm run test:unit:_run
environment:
NODE_ENV: test
NODE_OPTIONS: "--unhandled-rejections=strict"
test_acceptance:
@ -21,23 +22,22 @@ services:
REDIS_HOST: redis
MONGO_HOST: mongo
POSTGRES_HOST: postgres
AWS_S3_ENDPOINT: http://s3:9090
AWS_S3_PATH_STYLE: 'true'
AWS_ACCESS_KEY_ID: fake
AWS_SECRET_ACCESS_KEY: fake
GCS_API_ENDPOINT: gcs:9090
GCS_API_SCHEME: http
GCS_PROJECT_ID: fake
STORAGE_EMULATOR_HOST: http://gcs:9090/storage/v1
MOCHA_GREP: ${MOCHA_GREP}
NODE_ENV: test
NODE_OPTIONS: "--unhandled-rejections=strict"
ENABLE_CONVERSIONS: "true"
USE_PROM_METRICS: "true"
AWS_S3_USER_FILES_BUCKET_NAME: fake_user_files
AWS_S3_TEMPLATE_FILES_BUCKET_NAME: fake_template_files
AWS_S3_PUBLIC_FILES_BUCKET_NAME: fake_public_files
AWS_S3_ENDPOINT: http://s3:9090
AWS_ACCESS_KEY_ID: fake
AWS_SECRET_ACCESS_KEY: fake
AWS_S3_PATH_STYLE: 'true'
GCS_API_ENDPOINT: gcs:9090
GCS_API_SCHEME: http
GCS_USER_FILES_BUCKET_NAME: fake_userfiles
GCS_TEMPLATE_FILES_BUCKET_NAME: fake_templatefiles
GCS_PUBLIC_FILES_BUCKET_NAME: fake_publicfiles
STORAGE_EMULATOR_HOST: http://gcs:9090/storage/v1
depends_on:
s3:
condition: service_healthy
@ -59,8 +59,7 @@ services:
context: test/acceptance/deps
dockerfile: Dockerfile.s3mock
environment:
- initialBuckets=fake_user_files,fake_template_files,fake_public_files
- initialBuckets=fake_user_files,fake_template_files,fake_public_files,bucket
gcs:
build:
context: test/acceptance/deps

View file

@ -15,7 +15,8 @@ services:
environment:
MOCHA_GREP: ${MOCHA_GREP}
NODE_ENV: test
command: npm run test:unit
NODE_OPTIONS: "--unhandled-rejections=strict"
command: npm run --silent test:unit
user: node
test_acceptance:
@ -30,39 +31,37 @@ services:
REDIS_HOST: redis
MONGO_HOST: mongo
POSTGRES_HOST: postgres
MOCHA_GREP: ${MOCHA_GREP}
LOG_LEVEL: ERROR
NODE_ENV: test
ENABLE_CONVERSIONS: "true"
USE_PROM_METRICS: "true"
AWS_S3_USER_FILES_BUCKET_NAME: fake_user_files
AWS_S3_TEMPLATE_FILES_BUCKET_NAME: fake_template_files
AWS_S3_PUBLIC_FILES_BUCKET_NAME: fake_public_files
AWS_S3_ENDPOINT: http://s3:9090
AWS_S3_PATH_STYLE: 'true'
AWS_ACCESS_KEY_ID: fake
AWS_SECRET_ACCESS_KEY: fake
GCS_API_ENDPOINT: gcs:9090
GCS_API_SCHEME: http
GCS_USER_FILES_BUCKET_NAME: fake_userfiles
GCS_TEMPLATE_FILES_BUCKET_NAME: fake_templatefiles
GCS_PUBLIC_FILES_BUCKET_NAME: fake_publicfiles
GCS_PROJECT_ID: fake
STORAGE_EMULATOR_HOST: http://gcs:9090/storage/v1
MOCHA_GREP: ${MOCHA_GREP}
LOG_LEVEL: ERROR
NODE_ENV: test
NODE_OPTIONS: "--unhandled-rejections=strict"
ENABLE_CONVERSIONS: "true"
USE_PROM_METRICS: "true"
AWS_S3_USER_FILES_BUCKET_NAME: fake_user_files
AWS_S3_TEMPLATE_FILES_BUCKET_NAME: fake_template_files
AWS_S3_PUBLIC_FILES_BUCKET_NAME: fake_public_files
user: node
depends_on:
s3:
condition: service_healthy
gcs:
condition: service_healthy
command: npm run test:acceptance
command: npm run --silent test:acceptance
s3:
build:
context: test/acceptance/deps
dockerfile: Dockerfile.s3mock
environment:
- initialBuckets=fake_user_files,fake_template_files,fake_public_files
- initialBuckets=fake_user_files,fake_template_files,fake_public_files,bucket
gcs:
build:
context: test/acceptance/deps

View file

@ -8,7 +8,6 @@
"execMap": {
"js": "npm run start"
},
"watch": [
"app/js/",
"app.js",

View file

@ -2521,9 +2521,9 @@
"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==",
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-chai-friendly/-/eslint-plugin-chai-friendly-0.5.0.tgz",
"integrity": "sha512-Pxe6z8C9fP0pn2X2nGFU/b3GBOCM/5FVus1hsMwJsXP3R7RiXFl7g0ksJbsc0GxiLyidTW4mEFk77qsNn7Tk7g==",
"dev": true
},
"eslint-plugin-es": {
@ -4737,9 +4737,9 @@
"dev": true
},
"prettier": {
"version": "1.19.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz",
"integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==",
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz",
"integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==",
"dev": true
},
"prettier-eslint": {
@ -4938,6 +4938,12 @@
"mimic-fn": "^1.0.0"
}
},
"prettier": {
"version": "1.19.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz",
"integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==",
"dev": true
},
"restore-cursor": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz",

View file

@ -13,7 +13,7 @@
"test:unit": "npm run test:unit:_run -- --grep=$MOCHA_GREP",
"start": "node $NODE_APP_OPTIONS app.js",
"nodemon": "nodemon --config nodemon.json",
"lint": "node_modules/.bin/eslint app test *.js",
"lint": "node_modules/.bin/eslint --max-warnings 0 .",
"format": "node_modules/.bin/prettier-eslint $PWD'/**/*.js' --list-different",
"format:fix": "node_modules/.bin/prettier-eslint $PWD'/**/*.js' --write",
"test:acceptance:_run": "mocha --recursive --reporter spec --timeout 15000 --exit $@ test/acceptance/js",
@ -46,18 +46,19 @@
"chai-as-promised": "^7.1.1",
"disrequire": "^1.1.0",
"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-plugin-chai-expect": "^2.1.0",
"eslint-plugin-chai-friendly": "^0.6.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-chai-friendly": "^0.5.0",
"eslint-plugin-import": "^2.20.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-standard": "^4.0.1",
"mocha": "7.2.0",
"mongodb": "^3.5.9",
"prettier": "^2.0.0",
"prettier-eslint": "^9.0.2",
"prettier-eslint-cli": "^5.0.0",
"sandboxed-module": "2.0.4",

View file

@ -33,7 +33,7 @@ class FilestoreApp {
this.server = this.app.listen(
Settings.internal.filestore.port,
'localhost',
err => {
(err) => {
if (err) {
return reject(err)
}
@ -110,7 +110,7 @@ class FilestoreApp {
// unload the app, as we may be doing this on multiple runs with
// different settings, which affect startup in some cases
const files = await fsReaddir(Path.resolve(__dirname, '../../../app/js'))
files.forEach(file => {
files.forEach((file) => {
disrequire(Path.resolve(__dirname, '../../../app/js', file))
})
disrequire(Path.resolve(__dirname, '../../../app'))

View file

@ -29,7 +29,7 @@ if (!process.env.AWS_ACCESS_KEY_ID) {
throw new Error('please provide credentials for the AWS S3 test server')
}
process.on('unhandledRejection', e => {
process.on('unhandledRejection', (e) => {
// eslint-disable-next-line no-console
console.log('** Unhandled Promise Rejection **\n', e)
throw e
@ -51,7 +51,7 @@ describe('Filestore', function() {
const badSockets = []
for (const socket of stdout.split('\n')) {
const fields = socket.split(' ').filter(part => part !== '')
const fields = socket.split(' ').filter((part) => part !== '')
if (
fields.length > 2 &&
parseInt(fields[1]) &&
@ -79,7 +79,7 @@ describe('Filestore', function() {
}
// redefine the test suite for every available backend
Object.keys(BackendSettings).forEach(backend => {
Object.keys(BackendSettings).forEach((backend) => {
describe(backend, function () {
let app, previousEgress, previousIngress, metricPrefix, projectId
@ -433,7 +433,7 @@ describe('Filestore', function() {
for (let i = 0; i < 5; i++) {
// test is not 100% reliable, so repeat
// create a new connection and have it time out before reading any data
await new Promise(resolve => {
await new Promise((resolve) => {
const streamThatHangs = new Stream.PassThrough()
const stream = request({ url: fileUrl, timeout: 1000 })
stream.pipe(streamThatHangs)

View file

@ -25,7 +25,7 @@ async function getMetric(filestoreUrl, metric) {
function streamToString(stream) {
const chunks = []
return new Promise((resolve, reject) => {
stream.on('data', chunk => chunks.push(chunk))
stream.on('data', (chunk) => chunks.push(chunk))
stream.on('error', reject)
stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')))
stream.resume()

View file

@ -104,7 +104,7 @@ describe('FileController', function() {
it('should send a 200 if the cacheWarm param is true', function (done) {
req.query.cacheWarm = true
res.sendStatus = statusCode => {
res.sendStatus = (statusCode) => {
statusCode.should.equal(200)
done()
}
@ -220,7 +220,7 @@ describe('FileController', function() {
new Errors.NotFoundError({ message: 'not found', info: {} })
)
res.sendStatus = code => {
res.sendStatus = (code) => {
expect(code).to.equal(404)
done()
}
@ -238,7 +238,7 @@ describe('FileController', function() {
describe('insertFile', function () {
it('should send bucket name key and res to PersistorManager', function (done) {
res.sendStatus = code => {
res.sendStatus = (code) => {
expect(FileHandler.insertFile).to.have.been.calledWith(bucket, key, req)
expect(code).to.equal(200)
done()
@ -262,7 +262,7 @@ describe('FileController', function() {
})
it('should send bucket name and both keys to PersistorManager', function (done) {
res.sendStatus = code => {
res.sendStatus = (code) => {
code.should.equal(200)
expect(PersistorManager.copyObject).to.have.been.calledWith(
bucket,
@ -278,7 +278,7 @@ describe('FileController', function() {
PersistorManager.copyObject.rejects(
new Errors.NotFoundError({ message: 'not found', info: {} })
)
res.sendStatus = code => {
res.sendStatus = (code) => {
code.should.equal(404)
done()
}
@ -287,7 +287,7 @@ describe('FileController', function() {
it('should send an error if there was an error', function (done) {
PersistorManager.copyObject.rejects(error)
FileController.copyFile(req, res, err => {
FileController.copyFile(req, res, (err) => {
expect(err).to.equal(error)
done()
})
@ -296,7 +296,7 @@ describe('FileController', function() {
describe('delete file', function () {
it('should tell the file handler', function (done) {
res.sendStatus = code => {
res.sendStatus = (code) => {
code.should.equal(204)
expect(FileHandler.deleteFile).to.have.been.calledWith(bucket, key)
done()
@ -313,7 +313,7 @@ describe('FileController', function() {
describe('delete project', function () {
it('should tell the file handler', function (done) {
res.sendStatus = code => {
res.sendStatus = (code) => {
code.should.equal(204)
expect(FileHandler.deleteProject).to.have.been.calledWith(bucket, key)
done()
@ -331,7 +331,7 @@ describe('FileController', function() {
describe('directorySize', function () {
it('should return total directory size bytes', function (done) {
FileController.directorySize(req, {
json: result => {
json: (result) => {
expect(result['total bytes']).to.equal(fileSize)
done()
}

View file

@ -93,7 +93,7 @@ describe('FileHandler', function() {
const stream = 'stream'
it('should send file to the filestore', function (done) {
FileHandler.insertFile(bucket, key, stream, err => {
FileHandler.insertFile(bucket, key, stream, (err) => {
expect(err).not.to.exist
expect(PersistorManager.sendStream).to.have.been.calledWith(
bucket,
@ -105,7 +105,7 @@ describe('FileHandler', function() {
})
it('should not make a delete request for the convertedKey folder', function (done) {
FileHandler.insertFile(bucket, key, stream, err => {
FileHandler.insertFile(bucket, key, stream, (err) => {
expect(err).not.to.exist
expect(PersistorManager.deleteDirectory).not.to.have.been.called
done()
@ -116,7 +116,7 @@ describe('FileHandler', function() {
KeyBuilder.getConvertedFolderKey.returns(
'5ecba29f1a294e007d0bccb4/v/0/pdf'
)
FileHandler.insertFile(bucket, key, stream, err => {
FileHandler.insertFile(bucket, key, stream, (err) => {
expect(err).not.to.exist
done()
})
@ -124,7 +124,7 @@ describe('FileHandler', function() {
it('should throw an error when the key is in the wrong format', function (done) {
KeyBuilder.getConvertedFolderKey.returns('wombat')
FileHandler.insertFile(bucket, key, stream, err => {
FileHandler.insertFile(bucket, key, stream, (err) => {
expect(err).to.exist
done()
})
@ -136,7 +136,7 @@ describe('FileHandler', function() {
})
it('should delete the convertedKey folder', function (done) {
FileHandler.insertFile(bucket, key, stream, err => {
FileHandler.insertFile(bucket, key, stream, (err) => {
expect(err).not.to.exist
expect(PersistorManager.deleteDirectory).to.have.been.calledWith(
bucket,
@ -150,7 +150,7 @@ describe('FileHandler', function() {
describe('deleteFile', function () {
it('should tell the filestore manager to delete the file', function (done) {
FileHandler.deleteFile(bucket, key, err => {
FileHandler.deleteFile(bucket, key, (err) => {
expect(err).not.to.exist
expect(PersistorManager.deleteObject).to.have.been.calledWith(
bucket,
@ -161,7 +161,7 @@ describe('FileHandler', function() {
})
it('should not tell the filestore manager to delete the cached folder', function (done) {
FileHandler.deleteFile(bucket, key, err => {
FileHandler.deleteFile(bucket, key, (err) => {
expect(err).not.to.exist
expect(PersistorManager.deleteDirectory).not.to.have.been.called
done()
@ -172,7 +172,7 @@ describe('FileHandler', function() {
KeyBuilder.getConvertedFolderKey.returns(
'5ecba29f1a294e007d0bccb4/v/0/pdf'
)
FileHandler.deleteFile(bucket, key, err => {
FileHandler.deleteFile(bucket, key, (err) => {
expect(err).not.to.exist
done()
})
@ -180,7 +180,7 @@ describe('FileHandler', function() {
it('should throw an error when the key is in the wrong format', function (done) {
KeyBuilder.getConvertedFolderKey.returns('wombat')
FileHandler.deleteFile(bucket, key, err => {
FileHandler.deleteFile(bucket, key, (err) => {
expect(err).to.exist
done()
})
@ -192,7 +192,7 @@ describe('FileHandler', function() {
})
it('should delete the convertedKey folder', function (done) {
FileHandler.deleteFile(bucket, key, err => {
FileHandler.deleteFile(bucket, key, (err) => {
expect(err).not.to.exist
expect(PersistorManager.deleteDirectory).to.have.been.calledWith(
bucket,
@ -206,7 +206,7 @@ describe('FileHandler', function() {
describe('deleteProject', function () {
it('should tell the filestore manager to delete the folder', function (done) {
FileHandler.deleteProject(bucket, projectKey, err => {
FileHandler.deleteProject(bucket, projectKey, (err) => {
expect(err).not.to.exist
expect(PersistorManager.deleteDirectory).to.have.been.calledWith(
bucket,
@ -217,7 +217,7 @@ describe('FileHandler', function() {
})
it('should throw an error when the key is in the wrong format', function (done) {
FileHandler.deleteProject(bucket, 'wombat', err => {
FileHandler.deleteProject(bucket, 'wombat', (err) => {
expect(err).to.exist
done()
})
@ -235,7 +235,7 @@ describe('FileHandler', function() {
it('should pass options through to PersistorManager', function (done) {
const options = { start: 0, end: 8 }
FileHandler.getFile(bucket, key, options, err => {
FileHandler.getFile(bucket, key, options, (err) => {
expect(err).not.to.exist
expect(PersistorManager.getObjectStream).to.have.been.calledWith(
bucket,
@ -305,7 +305,7 @@ describe('FileHandler', function() {
describe('when a style is defined', function () {
it('generates a thumbnail when requested', function (done) {
FileHandler.getFile(bucket, key, { style: 'thumbnail' }, err => {
FileHandler.getFile(bucket, key, { style: 'thumbnail' }, (err) => {
expect(err).not.to.exist
expect(FileConverter.promises.thumbnail).to.have.been.called
expect(FileConverter.promises.preview).not.to.have.been.called
@ -314,7 +314,7 @@ describe('FileHandler', function() {
})
it('generates a preview when requested', function (done) {
FileHandler.getFile(bucket, key, { style: 'preview' }, err => {
FileHandler.getFile(bucket, key, { style: 'preview' }, (err) => {
expect(err).not.to.exist
expect(FileConverter.promises.thumbnail).not.to.have.been.called
expect(FileConverter.promises.preview).to.have.been.called
@ -385,7 +385,7 @@ describe('FileHandler', function() {
describe('getDirectorySize', function () {
it('should call the filestore manager to get directory size', function (done) {
FileHandler.getDirectorySize(bucket, key, err => {
FileHandler.getDirectorySize(bucket, key, (err) => {
expect(err).not.to.exist
expect(PersistorManager.directorySize).to.have.been.calledWith(
bucket,

View file

@ -29,7 +29,7 @@ describe('ImageOptimiser', function() {
describe('compressPng', function () {
it('should convert the file', function (done) {
ImageOptimiser.compressPng(sourcePath, err => {
ImageOptimiser.compressPng(sourcePath, (err) => {
expect(err).not.to.exist
expect(SafeExec.promises).to.have.been.calledWith([
'optipng',
@ -41,7 +41,7 @@ describe('ImageOptimiser', function() {
it('should return the error', function (done) {
SafeExec.promises.rejects('wombat herding failure')
ImageOptimiser.compressPng(sourcePath, err => {
ImageOptimiser.compressPng(sourcePath, (err) => {
expect(err.toString()).to.equal('wombat herding failure')
done()
})
@ -54,7 +54,7 @@ describe('ImageOptimiser', function() {
beforeEach(function (done) {
SafeExec.promises.rejects(expectedError)
ImageOptimiser.compressPng(sourcePath, err => {
ImageOptimiser.compressPng(sourcePath, (err) => {
error = err
done()
})

View file

@ -57,7 +57,7 @@ describe('LocalFileWriter', function() {
})
it('should wrap the error', function () {
LocalFileWriter.writeStream(readStream, filename, err => {
LocalFileWriter.writeStream(readStream, filename, (err) => {
expect(err).to.exist
expect(err.cause).to.equal(error)
})
@ -73,7 +73,7 @@ describe('LocalFileWriter', function() {
describe('deleteFile', function () {
it('should unlink the file', function (done) {
LocalFileWriter.deleteFile(fsPath, err => {
LocalFileWriter.deleteFile(fsPath, (err) => {
expect(err).not.to.exist
expect(fs.unlink).to.have.been.calledWith(fsPath)
done()
@ -81,7 +81,7 @@ describe('LocalFileWriter', function() {
})
it('should not call unlink with an empty path', function (done) {
LocalFileWriter.deleteFile('', err => {
LocalFileWriter.deleteFile('', (err) => {
expect(err).not.to.exist
expect(fs.unlink).not.to.have.been.called
done()
@ -92,7 +92,7 @@ describe('LocalFileWriter', function() {
const error = new Error('file not found')
error.code = 'ENOENT'
fs.unlink = sinon.stub().yields(error)
LocalFileWriter.deleteFile(fsPath, err => {
LocalFileWriter.deleteFile(fsPath, (err) => {
expect(err).not.to.exist
done()
})
@ -101,7 +101,7 @@ describe('LocalFileWriter', function() {
it('should wrap the error', function (done) {
const error = new Error('failed to reticulate splines')
fs.unlink = sinon.stub().yields(error)
LocalFileWriter.deleteFile(fsPath, err => {
LocalFileWriter.deleteFile(fsPath, (err) => {
expect(err).to.exist
expect(err.cause).to.equal(error)
done()

View file

@ -35,14 +35,14 @@ describe('SafeExec', function() {
it('should error when conversions are disabled', function (done) {
settings.enableConversions = false
safeExec(['/bin/echo', 'hello'], options, err => {
safeExec(['/bin/echo', 'hello'], options, (err) => {
expect(err).to.exist
done()
})
})
it('should execute a command with non-zero exit status', function (done) {
safeExec(['/usr/bin/env', 'false'], options, err => {
safeExec(['/usr/bin/env', 'false'], options, (err) => {
expect(err).to.exist
expect(err.name).to.equal('FailedCommandError')
expect(err.code).to.equal(1)
@ -53,7 +53,7 @@ describe('SafeExec', function() {
})
it('should handle an invalid command', function (done) {
safeExec(['/bin/foobar'], options, err => {
safeExec(['/bin/foobar'], options, (err) => {
err.code.should.equal('ENOENT')
done()
})
@ -63,7 +63,7 @@ describe('SafeExec', function() {
safeExec(
['/bin/sleep', '10'],
{ timeout: 500, killSignal: 'SIGTERM' },
err => {
(err) => {
expect(err).to.exist
expect(err.name).to.equal('FailedCommandError')
expect(err.code).to.equal('SIGTERM')