<commit_before>"use strict";

var path = require("path");
var async = require("async");
var shellExec = require('child_process').exec;
var createFakeApi = require('./helpers/fake-api.js');

describe('Hydration should be cleaned every time', function() {
  var fakeApi = createFakeApi();

  fakeApi.patch('/result', function(req, res,next) {
    res.send(204);
    next();
  });
  before(function() {
    fakeApi.listen(4243);
  });

  after(function() {
    fakeApi.close();
  });

  it('on normal workflow', function(done) {
    this.timeout(10000);

    var nodeProccessesAtStart;
    async.waterfall([
      function getActualNodeProccesses(cb) {
        shellExec('ps aux | grep "[n]ode" -c', cb);
      },
      function setNodeProcessesNumber(stdout, stderr, cb) {
        nodeProccessesAtStart = parseInt(stdout);
        cb();
      },
      function hydrateManyTimes(cb) {
        var config = {
          hydrater_function: path.resolve(__dirname, './hydraters/grep-hydrater.js'),
          logger: function() {},
        };
        var hydrate = require('../lib/helpers/hydrater.js')(config.hydrater_function, config.logger);

        var task = {
          file_path: "http://127.0.0.1:4243/afile",
          callback: "http://127.0.0.1:4243/result",
          document: {
            id: "azerty"
          },
        };

        var hydrationCount = 0;<commit_msg>Update cleaning.js<commit_after>"use strict";

var path = require("path");
var async = require("async");
var shellExec = require('child_process').exec;
var createFakeApi = require('./helpers/fake-api.js');

describe('Hydration should be cleaned every time', function() {
  var fakeApi = createFakeApi();

  fakeApi.patch('/result', function(req, res,next) {
    res.send(204);
    next();
  });
  before(function() {
    fakeApi.listen(4243);
  });

  after(function() {
    fakeApi.close();
  });

  it('on normal workflow', function(done) {
    this.timeout(10000);

    var nodeProccessesAtStart;
    async.waterfall([
      function getCurrentNodeProccesses(cb) {
        shellExec('ps aux | grep "[n]ode" -c', cb);
      },
      function setNodeProcessesNumber(stdout, stderr, cb) {
        nodeProccessesAtStart = parseInt(stdout);
        cb();
      },
      function hydrateManyTimes(cb) {
        var config = {
          hydrater_function: path.resolve(__dirname, './hydraters/grep-hydrater.js'),
          logger: function() {},
        };
        var hydrate = require('../lib/helpers/hydrater.js')(config.hydrater_function, config.logger);

        var task = {
          file_path: "http://127.0.0.1:4243/afile",
          callback: "http://127.0.0.1:4243/result",
          document: {
            id: "azerty"
          },
        };

        var hydrationCount = 0;
{'fraction_non_alphanumeric': 0.15677045619116584, 'fraction_numerical': 0.02389572773352643, 'mean_word_length': 2.6499339498018495, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7439852', 'n_tokens_mistral': 919, 'n_tokens_neox': 851, 'n_words': 162}