now wating correctly for mongo by checking logMessage

This commit is contained in:
Philipp Kunz 2016-09-12 14:45:08 +02:00
parent ee3c3580d3
commit 50a6a1a690
2 changed files with 37 additions and 16 deletions

View File

@ -1,6 +1,8 @@
"use strict"; "use strict";
require('typings-test'); require('typings-test');
let portastic = require('portastic');
const shelljs = require('shelljs'); const shelljs = require('shelljs');
// the tested module
const smartdata = require('../dist/index'); const smartdata = require('../dist/index');
let mongoChildProcess; let mongoChildProcess;
let testDbConnection; let testDbConnection;
@ -8,8 +10,17 @@ let testDbCollection;
describe('mongodb', function () { describe('mongodb', function () {
it('should start mongodb', function (done) { it('should start mongodb', function (done) {
this.timeout(10000); this.timeout(10000);
mongoChildProcess = shelljs.exec('mongod --dbpath=./test/data --port 27017', { async: true }); mongoChildProcess = shelljs.exec('mongod --dbpath=./test/data --port 27017', { async: true, silent: true });
setTimeout(() => { done(); }, 5000); // give mongodb it some time to complete startup let doneCalled = false;
mongoChildProcess.stdout.on('data', function (data) {
console.log(data);
if (!doneCalled) {
if (/waiting for connections on port 27017/.test(data)) {
doneCalled = true;
done();
}
}
});
}); });
}); });
describe('smartdata', function () { describe('smartdata', function () {
@ -31,4 +42,4 @@ describe('mongodb', function () {
mongoChildProcess.kill('SIGTERM'); mongoChildProcess.kill('SIGTERM');
}); });
}); });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FDUCxDQUFDLENBRG9CO0FBQ3JCLE1BQVksT0FBTyxXQUFNLFNBQ3pCLENBQUMsQ0FEaUM7QUFFbEMsTUFBWSxTQUFTLFdBQU0sZUFHM0IsQ0FBQyxDQUh5QztBQUcxQyxJQUFJLGlCQUFpQixDQUFBO0FBQ3JCLElBQUksZ0JBQXdDLENBQUE7QUFDNUMsSUFBSSxnQkFBNk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0FBQTtBQUVGLFFBQVEsQ0FBQyxTQUFTLEVBQUU7SUFDaEIsRUFBRSxDQUFDLHFCQUFxQixFQUFFO1FBQ3RCLElBQUksQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLENBQUE7UUFDbkIsT0FBTyxDQUFDLElBQUksQ0FBQyx3Q0FBd0MsQ0FBQyxDQUFBO1FBQ3RELGlCQUFpQixDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsQ0FBQTtJQUNyQyxDQUFDLENBQUMsQ0FBQTtBQUNOLENBQUMsQ0FBQyxDQUFBIn0=

View File

@ -1,19 +1,29 @@
import 'typings-test' import 'typings-test'
import * as shelljs from 'shelljs' import * as shelljs from 'shelljs'
import * as should from 'should' import * as should from 'should'
import * as smartdata from '../dist/index'
// the tested module
import * as smartdata from '../dist/index'
let mongoChildProcess let mongoChildProcess
let testDbConnection: smartdata.DbConnection let testDbConnection: smartdata.DbConnection
let testDbCollection: smartdata.DbCollection<any> let testDbCollection: smartdata.DbCollection<any>
describe('mongodb', function () { describe('mongodb', function () {
it('should start mongodb', function (done) { it('should start mongodb', function (done) {
this.timeout(10000) this.timeout(10000)
mongoChildProcess = shelljs.exec('mongod --dbpath=./test/data --port 27017',{async: true}) mongoChildProcess = shelljs.exec('mongod --dbpath=./test/data --port 27017', { async: true, silent: true })
setTimeout(() => { done() }, 5000) // give mongodb it some time to complete startup let doneCalled = false
mongoChildProcess.stdout.on('data', function(data) {
console.log(data)
if (!doneCalled){
if (/waiting for connections on port 27017/.test(data)) {
doneCalled = true
done()
}
}
})
}) })
}) })
describe('smartdata', function () { describe('smartdata', function () {