Skip to content

Commit

Permalink
Updated testing framework
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaly Puzrin committed Mar 17, 2014
1 parent 85e3d6f commit a329a34
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 76 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ dependencies:
cleanup:
# cleanup assets
rm -rf public/assets
rm -rf .cache

# needed for travis
setup:
Expand All @@ -119,8 +120,9 @@ setup:


test: cleanup lint
node ./fontello.js server --test
mocha --timeout 40000 ./test/server/
#node ./fontello.js server --test
@NODECA_ENV=test node ./fontello.js migrate --all
@NODECA_ENV=test ./fontello.js test


todo:
Expand Down
29 changes: 2 additions & 27 deletions cli/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,7 @@ module.exports.parserParameters = {
};


module.exports.commandLineArguments = [
{
args: ['--test'],
options: {
help: 'Start server an terminates immediately, ' +
'with code 0 on init success.',
action: 'storeTrue'
}
}
];
module.exports.commandLineArguments = [];


module.exports.run = function (N, args, callback) {
Expand All @@ -32,21 +23,5 @@ module.exports.run = function (N, args, callback) {
'init:models',
'init:bundle',
'init:server'
], N,

function (err) {
if (err) {
callback(err);
return;
}

// for `--test` just exit on success
if (args.test) {
process.stdout.write('Server exec test OK\n');
process.exit(0);
}

callback();
}
);
], N, callback);
};
3 changes: 3 additions & 0 deletions cli/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ module.exports.run = function (N, args, callback) {
}
});

// Expose N to globals for tests
global.TEST_N = N;

mocha.run(function (err) {
if (err) {
callback(err);
Expand Down
5 changes: 1 addition & 4 deletions config/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@
^test:
database:

mongo:
host: localhost
port: 27017
database: fontello-test
mongo: localhost/fontello-test
6 changes: 6 additions & 0 deletions config/test.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Configuration for testing

^test:
database:

mongo: localhost/fontello-test
3 changes: 0 additions & 3 deletions test/mocha.opts

This file was deleted.

40 changes: 0 additions & 40 deletions test/server/generic.js

This file was deleted.

25 changes: 25 additions & 0 deletions test/server/ping.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*global describe, it*/


'use strict';


var request = require('supertest')('http://localhost:3000');


describe('HTTP alive', function () {

it('/ GET', function (done) {
request
.get('/')
.expect(/fontello/)
.expect(200, done);
});

it('/ HEAD', function (done) {
request
.head('/')
.expect('')
.expect(200, done);
});
});

0 comments on commit a329a34

Please sign in to comment.