Skip to content

Commit

Permalink
Merge pull request #26 from makeomatic/feat/codecov
Browse files Browse the repository at this point in the history
Feat/codecov
  • Loading branch information
AVVS committed Jan 6, 2016
2 parents 5872dfd + d9326c1 commit 8c85a50
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .istanbul.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
instrumentation:
root: src

reporting:
reports:
- lcovonly
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Microservice for handling users over AMQP transport layer

[![npm version](https://badge.fury.io/js/ms-users.svg)](https://badge.fury.io/js/ms-users)
[![Build Status](https://semaphoreci.com/api/v1/projects/27a0c3e3-ba64-49e1-a1be-7655eae716b9/632945/shields_badge.svg)](https://semaphoreci.com/makeomatic/ms-users)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![codecov.io](https://codecov.io/github/makeomatic/ms-users/coverage.svg?branch=master)](https://codecov.io/github/makeomatic/ms-users?branch=master)

## Installation

`npm i ms-users -S`
Expand Down
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "ms-users",
"version": "0.9.3",
"description": "Core of the microservice for handling users",
"main": "./lib/index.js",
"scripts": {
"compile": "./node_modules/.bin/babel -d ./lib ./src",
"rebuild": "if [ \"$SKIP_REBUILD\" != \"1\" ]; then npm rebuild; fi",
"prepublish": "npm run compile",
"test": "./test/docker.sh",
"start": "node ./bin/mservice.js | ./node_modules/.bin/bunyan -o short"
"start": "node ./bin/mservice.js | ./node_modules/.bin/bunyan -o short",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
"repository": {
"type": "git",
"url": "git+https://github.com/makeomatic/ms-users.git"
"url": "https://github.com/makeomatic/ms-users.git"
},
"author": "Vitaly Aminev <[email protected]>",
"license": "MIT",
Expand Down Expand Up @@ -54,17 +54,24 @@
"babel-preset-stage-0": "^6.3.13",
"babel-register": "^6.3.13",
"chai": "^3.4.1",
"codecov.io": "^0.1.6",
"cz-conventional-changelog": "^1.1.5",
"eslint": "^1.10.3",
"eslint-config-airbnb": "^2.1.1",
"eslint-plugin-mocha": "^1.1.0",
"faker": "^3.0.1",
"isparta": "^4.0.0",
"istanbul": "^0.4.0",
"json": "^9.0.3",
"mocha": "^2.3.3",
"mocha-multi": "^0.7.2",
"semantic-release": "^4.3.5",
"server-destroy": "^1.0.1",
"sinon": "^1.17.2"
},
"release": {
"verifyConditions": []
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
Expand Down
17 changes: 17 additions & 0 deletions test/aggregate-report.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const fs = require('fs');
const glob = require('glob');
const istanbul = require('istanbul');
const reporter = new istanbul.Reporter();
const collector = new istanbul.Collector();

reporter.addAll(['lcov', 'html', 'text-summary']);

glob.sync('./coverage/**/coverage*.json').forEach(file => {
process.stdout.write('adding file: ' + file + '\n');
collector.add(JSON.parse(fs.readFileSync(file)));
});

reporter.write(collector, true, () => {
process.stdout.write('report combined...\n');
process.exit(0);
});
2 changes: 1 addition & 1 deletion test/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('chai').config.includeStack = true;
const { expect } = require('chai');
const Users = require('../lib');
const Users = require('../src');

global.Promise = require('bluebird');

Expand Down
18 changes: 16 additions & 2 deletions test/docker.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/bin/bash

export NODE_ENV=development
BIN=./node_modules/.bin
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DC="$DIR/docker-compose.yml"
PATH=$PATH:$DIR/.bin/
COMPOSE=$(which docker-compose)
MOCHA=./node_modules/.bin/mocha
MOCHA=$BIN/_mocha
COVER="$BIN/isparta cover"
NODE=$BIN/babel-node
TESTS=test/suites/*.js

if [ -z "$NODE_VER" ]; then
Expand All @@ -28,6 +31,17 @@ trap finish EXIT
export IMAGE=makeomatic/alpine-node:$NODE_VER
$COMPOSE -f $DC up -d
$COMPOSE -f $DC run --rm tester npm run rebuild

echo "cleaning old coverage"
rm -rf ./coverage

echo "running tests"
for fn in $TESTS; do
$COMPOSE -f $DC run --rm tester $MOCHA $fn || exit 1
$COMPOSE -f $DC run --rm tester /bin/sh -c "$NODE $COVER --dir ./coverage/${fn##*/} $MOCHA -- $fn" || exit 1
done

echo "started generating combined coverage"
$COMPOSE -f $DC run --rm tester node ./test/aggregate-report.js

echo "uploading coverage report from ./coverage/lcov.info"
cat ./coverage/lcov.info | $BIN/codecov
4 changes: 2 additions & 2 deletions test/suites/activate.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* global inspectPromise */
const { expect } = require('chai');
const redisKey = require('../../lib/utils/key.js');
const redisKey = require('../../src/utils/key.js');
const URLSafeBase64 = require('urlsafe-base64');

describe('#activate', function activateSuite() {
const headers = { routingKey: 'users.activate' };
const emailValidation = require('../../lib/utils/send-email.js');
const emailValidation = require('../../src/utils/send-email.js');
const email = '[email protected]';

beforeEach(global.startService);
Expand Down
2 changes: 1 addition & 1 deletion test/suites/crypt.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { expect } = require('chai');

describe('encrypt/decrypt suite', function cryptoSuite() {
const emailValidation = require('../../lib/utils/send-email.js');
const emailValidation = require('../../src/utils/send-email.js');

beforeEach(global.startService);
afterEach(global.clearRedis);
Expand Down
2 changes: 1 addition & 1 deletion test/suites/list.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global inspectPromise */
const { expect } = require('chai');
const redisKey = require('../../lib/utils/key.js');
const redisKey = require('../../src/utils/key.js');
const ld = require('lodash');

describe('#list', function listSuite() {
Expand Down
4 changes: 2 additions & 2 deletions test/suites/login.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* global inspectPromise */
const { expect } = require('chai');
const redisKey = require('../../lib/utils/key.js');
const redisKey = require('../../src/utils/key.js');
const ld = require('lodash');

describe('#login', function loginSuite() {
const headers = { routingKey: 'users.login' };
const user = { username: '[email protected]', password: 'nicepassword', audience: '*.localhost' };
const userWithValidPassword = { username: '[email protected]', password: 'nicepassword1', audience: '*.localhost' };
const scrypt = require('../../lib/utils/scrypt.js');
const scrypt = require('../../src/utils/scrypt.js');

before(function test() {
return scrypt.hash(userWithValidPassword.password).then(pass => {
Expand Down
2 changes: 1 addition & 1 deletion test/suites/requestPassword.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global inspectPromise */
const { expect } = require('chai');
const redisKey = require('../../lib/utils/key.js');
const redisKey = require('../../src/utils/key.js');

describe('#requestPassword', function requestPasswordSuite() {
const headers = { routingKey: 'users.requestPassword' };
Expand Down
4 changes: 2 additions & 2 deletions test/suites/updatePassword.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* global inspectPromise */
const { expect } = require('chai');
const redisKey = require('../../lib/utils/key.js');
const redisKey = require('../../src/utils/key.js');

describe('#updatePassword', function updatePasswordSuite() {
const headers = { routingKey: 'users.updatePassword' };
const username = '[email protected]';
const password = '123';
const audience = '*.localhost';
const emailValidation = require('../../lib/utils/send-email.js');
const emailValidation = require('../../src/utils/send-email.js');

beforeEach(global.startService);
afterEach(global.clearRedis);
Expand Down
2 changes: 1 addition & 1 deletion test/suites/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const chai = require('chai');
const { expect } = chai;

describe('configuration suite', function ConfigurationSuite() {
const Users = require('../../lib');
const Users = require('../../src');

it('must throw on invalid configuration', function test() {
expect(function throwOnInvalidConfiguration() {
Expand Down
2 changes: 1 addition & 1 deletion test/suites/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('#verify', function verifySuite() {
});

describe('valid token', function suite() {
const jwt = require('../../lib/utils/jwt.js');
const jwt = require('../../src/utils/jwt.js');

beforeEach(function pretest() {
return this.users.router({ username: '[email protected]', password: '123', audience: 'test' }, { routingKey: 'users.register' });
Expand Down

0 comments on commit 8c85a50

Please sign in to comment.