Skip to content
This repository has been archived by the owner on Jun 21, 2019. It is now read-only.

Commit

Permalink
test scope fixes, env.sh handler for no arg, test.sh to run tests
Browse files Browse the repository at this point in the history
  • Loading branch information
YashoSharma committed Dec 9, 2016
1 parent 390620e commit 75f6b74
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"private": true,
"scripts": {
"test": ". resources/scripts/env.sh test && mocha 'test/test.js' -b —full-trace",
"test": "./resources/scripts/test.sh",
"dev": "./resources/scripts/startup.sh dev",
"prod": "./resources/scripts/startup.sh prod",
"dev-migrations": "source resources/scripts/env.sh dev && ./database/flyway.sh migrate",
Expand Down
29 changes: 16 additions & 13 deletions resources/scripts/env.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
#!/bin/bash

RED='\033[0;31m'
YELLOW='\033[0;33m'
NC='\033[0m'
if [ -f config/$1.config ]; then
while read line; do
[[ "$line" =~ ^#.*$ ]] && continue
[ -z "$line" ] && continue
eval export "$line";
done < config/$1.config
while read line; do
[[ "$line" =~ ^#.*$ ]] && continue
[ -z "$line" ] && continue
eval export "$line";
done < config/$1.config
else
if [[ $1 == *"dev"* ]]; then
echo -e "${RED}Missing a development configuration file\nPlease add a file called ${1}.config in the config directory\n${YELLOW}See the 'Configuration' section of the README for more information\n${NC}"
elif [[ $1 == *"prod"* ]]; then
echo -e "${RED}Missing a production configuration file\nPlease add a file called ${1}.config in the config directory\n${YELLOW}See the 'Configuration' section of the README for more information\n${NC}"
elif [[ $1 == *"test"* ]]; then
echo -e "${RED}Missing a test configuration file\nPlease add a file called ${1}.config in the config directory\n${YELLOW}See the 'Configuration' section of the README for more information\n${NC}"
if [[ $1 == *"dev"* ]]; then
echo -e "${RED}Missing a development configuration (dev.config)\n${NC}"
elif [[ $1 == *"prod"* ]]; then
echo -e "${RED}Missing a production configuration (prod.config)\n${NC}"
elif [[ $1 == *"test"* ]]; then
echo -e "${RED}Missing a test configuration (test.config)\n${NC}"
else
echo -e "${RED}Missing configuration parameter (specify 'prod', 'dev', or 'test')\n${NC}"
fi
exit 1
fi
exit 1
fi
4 changes: 4 additions & 0 deletions resources/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

source resources/scripts/env.sh test
mocha test/test.js --slow 500 --bail --check-leaks —full-trace
1 change: 1 addition & 0 deletions test/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('AuthService',function(){
});

describe('verify',function(){
var testUser;
before(function(done){
testUser = User.forge({ id: 1, email: '[email protected]' });
testUser.related('roles').add({ role: utils.roles.ATTENDEE });
Expand Down
9 changes: 5 additions & 4 deletions test/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ var expect = chai.expect;
describe('TokenService',function(){
describe('findTokenByValue',function(){
var testToken;
var _findByValue;
var tokenVal;

before(function(done){
tokenVal = utils.crypto.generateResetToken();
testToken = Token.forge({type: 'DEFAULT', value: tokenVal, user_id: 1});
Expand Down Expand Up @@ -74,7 +77,6 @@ describe('TokenService',function(){

describe('generateToken',function(){
var testUser;
var testToken;
before(function(done){

var _mockedTokens = {
Expand All @@ -89,12 +91,11 @@ describe('TokenService',function(){
};

testUser = User.forge({ id: 1, email: '[email protected]' });
testToken = Token.forge({type: 'DEFAULT', value: tokenVal, user_id: 1});



_where = sinon.stub(Token,'where');
var _where = sinon.stub(Token,'where');
_where.returns(_mockedWhere);

_save = sinon.stub(Token.prototype,'save');
var _save = sinon.stub(Token.prototype,'save');
_save.returns(_Promise.resolve(null));


done();
});
Expand Down

0 comments on commit 75f6b74

Please sign in to comment.