From 13400ea4d3dab9660c78171040c17aeffdad8489 Mon Sep 17 00:00:00 2001 From: Jonathan Cremin Date: Tue, 24 May 2016 18:03:10 +0100 Subject: [PATCH] Update tests for gitlab --- .gitlab-ci.yml | 14 ++++---------- app.js | 2 +- package.json | 3 ++- test/fixtures/mongo-file.js | 15 +++++++++++---- test/fixtures/mongo-user.js | 23 +++++++++++++++-------- 5 files changed, 33 insertions(+), 24 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f0114a0..b9127ef 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,21 +3,14 @@ services: - mongo stages: - - seed - test -seed: - stage: seed - image: mongo - script: - - mongo --host mongo hostr test/fixtures/mongo-user.js test/fixtures/mongo-file.js - tags: - - docker - test: stage: test before_script: - npm install + - jspm install + - node test/fixtures/mongo-user.js test/fixtures/mongo-file.js script: - npm test tags: @@ -27,4 +20,5 @@ cache: key: "$CI_BUILD_REF_NAME" untracked: true paths: - - node_modules + - node_modules + - web/public/jspm_packages diff --git a/app.js b/app.js index 93b09d3..29739e7 100644 --- a/app.js +++ b/app.js @@ -43,7 +43,7 @@ app.use(function* errorMiddleware(next) { try { yield next; } catch (err) { - if (!err.statusCode) { + if (!err.statusCode && this.raven) { this.raven.captureError(err); } throw err; diff --git a/package.json b/package.json index 6d28937..935a61e 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "init": "node -r babel/register -e \"require('./lib/storage')();\"", "jspm": "jspm install", "start": "npm run build && node -r babel/register app.js", - "test": "mongo hostr test/fixtures/mongo-*.js && mocha -r babel/register test/**/*.spec.js", + "test": "npm run test-seed && mocha -r babel/register test/**/*.spec.js", + "test-seed": "node test/fixtures/mongo-user.js && node test/fixtures/mongo-file.js", "watch": "parallelshell \"npm run watch-js\" \"npm run watch-sass\" \"npm run watch-server\"", "watch-js": "babel -Dw -m system -d web/public/build web/public/src", "watch-server": "nodemon -r babel/register app.js", diff --git a/test/fixtures/mongo-file.js b/test/fixtures/mongo-file.js index 6a3618e..4616bf0 100644 --- a/test/fixtures/mongo-file.js +++ b/test/fixtures/mongo-file.js @@ -1,5 +1,12 @@ -db.files.createIndex({ - "owner": 1, - "status": 1, - "time_added": -1 +const MongoClient = require('mongodb').MongoClient; +const url = 'mongodb://localhost:27017/hostr'; + +MongoClient.connect(url, function connect(err, db) { + const collection = db.collection('files'); + collection.createIndex({ + 'owner': 1, + 'status': 1, + 'time_added': -1, + }); + db.close(); }); diff --git a/test/fixtures/mongo-user.js b/test/fixtures/mongo-user.js index 9da07dd..01d5e42 100644 --- a/test/fixtures/mongo-user.js +++ b/test/fixtures/mongo-user.js @@ -1,9 +1,16 @@ -db.users.remove({ - "email": "test@hostr.co" -}); -db.users.save({ - "email": "test@hostr.co", - "salted_password": "$pbkdf2-256-1$2$kBhIDRqFwnF/1ms6ZHfME2o2$a48e8c350d26397fcc88bf0a7a2817b1cdcd1ffffe0521a5", - "joined": Math.ceil(Date.now()/1000), - "signup_ip": "127.0.0.1" +const MongoClient = require('mongodb').MongoClient; +const url = 'mongodb://localhost:27017/hostr'; + +MongoClient.connect(url, function connect(err, db) { + const collection = db.collection('users'); + collection.remove({ + 'email': 'test@hostr.co', + }); + collection.save({ + 'email': 'test@hostr.co', + 'salted_password': '$pbkdf2-256-1$2$kBhIDRqFwnF/1ms6ZHfME2o2$a48e8c350d26397fcc88bf0a7a2817b1cdcd1ffffe0521a5', + 'joined': Math.ceil(Date.now() / 1000), + 'signup_ip': '127.0.0.1', + }); + db.close(); });