@@ -4,6 +4,8 @@ var path = require("path");
44var async = require ( "async" ) ;
55var rarity = require ( "rarity" ) ;
66var shellExec = require ( 'child_process' ) . exec ;
7+
8+ var Childs = require ( '../lib/helpers/Childs' ) ;
79var createFakeApi = require ( './helpers/fake-api.js' ) ;
810
911var concurrencies = [ 1 , 2 ] ;
@@ -14,17 +16,24 @@ concurrencies.forEach(function(concurrency) {
1416 tasksPerProcess . forEach ( function ( _tasksPerProcess ) {
1517 describe ( 'Hydration should be cleaned every time with concurrency = ' + concurrency + ' & tasksPerProcess = ' + _tasksPerProcess , function ( ) {
1618 var fakeApi = createFakeApi ( ) ;
19+ var childs ;
1720
1821 fakeApi . patch ( '/result' , function ( req , res , next ) {
1922 res . send ( 204 ) ;
2023 next ( ) ;
2124 } ) ;
25+
2226 before ( function ( ) {
2327 fakeApi . listen ( 4243 ) ;
2428 } ) ;
2529
26- after ( function ( ) {
27- fakeApi . close ( ) ;
30+ afterEach ( function ( done ) {
31+ childs . stopAllChilds ( ) ;
32+ done ( ) ;
33+ } ) ;
34+
35+ after ( function ( done ) {
36+ fakeApi . close ( done ) ;
2837 } ) ;
2938
3039 it ( 'on normal workflow' , function ( done ) {
@@ -35,11 +44,12 @@ concurrencies.forEach(function(concurrency) {
3544 concurrency : concurrency ,
3645 logger : function ( ) { } ,
3746 } ;
47+ childs = new Childs ( config . concurrency , _tasksPerProcess ) ;
3848
39- process . env . TASKS_PER_PROCESS = _tasksPerProcess ;
40- var hydrate = require ( '../lib/helpers/hydrater.js' ) ( config . hydrater_function , config . concurrency , config . logger ) ;
49+ var hydrate = require ( '../lib/helpers/hydrater.js' ) ( config . hydrater_function , childs , config . logger ) ;
4150
42- var task = {
51+ var task = { } ;
52+ task . data = {
4353 file_path : "http://127.0.0.1:4243/afile" ,
4454 callback : "http://127.0.0.1:4243/result" ,
4555 document : {
@@ -82,11 +92,12 @@ concurrencies.forEach(function(concurrency) {
8292 concurrency : concurrency ,
8393 logger : function ( ) { } ,
8494 } ;
85- process . env . TASKS_PER_PROCESS = _tasksPerProcess ;
95+ var childs = new Childs ( config . concurrency , _tasksPerProcess ) ;
8696
87- var hydrate = require ( '../lib/helpers/hydrater.js' ) ( config . hydrater_function , config . concurrency , config . logger ) ;
97+ var hydrate = require ( '../lib/helpers/hydrater.js' ) ( config . hydrater_function , childs , config . logger ) ;
8898
89- var task = {
99+ var task = { } ;
100+ task . data = {
90101 file_path : "http://127.0.0.1:4243/afile" ,
91102 callback : "http://127.0.0.1:4243/result" ,
92103 document : {
@@ -129,11 +140,12 @@ concurrencies.forEach(function(concurrency) {
129140 concurrency : concurrency ,
130141 logger : function ( ) { } ,
131142 } ;
132- process . env . TASKS_PER_PROCESS = _tasksPerProcess ;
143+ var childs = new Childs ( config . concurrency , _tasksPerProcess ) ;
133144
134- var hydrate = require ( '../lib/helpers/hydrater.js' ) ( config . hydrater_function , config . concurrency , config . logger ) ;
145+ var hydrate = require ( '../lib/helpers/hydrater.js' ) ( config . hydrater_function , childs , config . logger ) ;
135146
136- var task = {
147+ var task = { } ;
148+ task . data = {
137149 file_path : "http://127.0.0.1:4243/afile" ,
138150 callback : "http://127.0.0.1:4243/result" ,
139151 document : {
0 commit comments