Update tests for gitlab

This commit is contained in:
Jonathan Cremin 2016-05-24 18:03:10 +01:00
parent b3479983aa
commit 13400ea4d3
5 changed files with 33 additions and 24 deletions

View file

@ -3,21 +3,14 @@ services:
- mongo - mongo
stages: stages:
- seed
- test - test
seed:
stage: seed
image: mongo
script:
- mongo --host mongo hostr test/fixtures/mongo-user.js test/fixtures/mongo-file.js
tags:
- docker
test: test:
stage: test stage: test
before_script: before_script:
- npm install - npm install
- jspm install
- node test/fixtures/mongo-user.js test/fixtures/mongo-file.js
script: script:
- npm test - npm test
tags: tags:
@ -27,4 +20,5 @@ cache:
key: "$CI_BUILD_REF_NAME" key: "$CI_BUILD_REF_NAME"
untracked: true untracked: true
paths: paths:
- node_modules - node_modules
- web/public/jspm_packages

2
app.js
View file

@ -43,7 +43,7 @@ app.use(function* errorMiddleware(next) {
try { try {
yield next; yield next;
} catch (err) { } catch (err) {
if (!err.statusCode) { if (!err.statusCode && this.raven) {
this.raven.captureError(err); this.raven.captureError(err);
} }
throw err; throw err;

View file

@ -16,7 +16,8 @@
"init": "node -r babel/register -e \"require('./lib/storage')();\"", "init": "node -r babel/register -e \"require('./lib/storage')();\"",
"jspm": "jspm install", "jspm": "jspm install",
"start": "npm run build && node -r babel/register app.js", "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": "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-js": "babel -Dw -m system -d web/public/build web/public/src",
"watch-server": "nodemon -r babel/register app.js", "watch-server": "nodemon -r babel/register app.js",

View file

@ -1,5 +1,12 @@
db.files.createIndex({ const MongoClient = require('mongodb').MongoClient;
"owner": 1, const url = 'mongodb://localhost:27017/hostr';
"status": 1,
"time_added": -1 MongoClient.connect(url, function connect(err, db) {
const collection = db.collection('files');
collection.createIndex({
'owner': 1,
'status': 1,
'time_added': -1,
});
db.close();
}); });

View file

@ -1,9 +1,16 @@
db.users.remove({ const MongoClient = require('mongodb').MongoClient;
"email": "test@hostr.co" const url = 'mongodb://localhost:27017/hostr';
});
db.users.save({ MongoClient.connect(url, function connect(err, db) {
"email": "test@hostr.co", const collection = db.collection('users');
"salted_password": "$pbkdf2-256-1$2$kBhIDRqFwnF/1ms6ZHfME2o2$a48e8c350d26397fcc88bf0a7a2817b1cdcd1ffffe0521a5", collection.remove({
"joined": Math.ceil(Date.now()/1000), 'email': 'test@hostr.co',
"signup_ip": "127.0.0.1" });
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();
}); });