<commit_before>'use strict';

const sinon = require('sinon');
var expect = require('chai').expect;
var QueryQueue = require('../queryqueue');
var before = require("mocha").before;
var after = require("mocha").after;
var mysql = sinon.mock(require('mysql'));

var config = {
    host: "localhost",
    user: "user",
    password: "password",
    database: "database"
};

function manyRunners(expected) {
    for (var i = 0; i < 10; i++) {
        singleRunner(expected);
    }
}

function singleRunner(expected) {
    var runner = QueryQueue.Runner(function (result, success) {
        expect(success).to.equal(expected);
    });
    for (var i = 0; i < 10; i++) {
        runner.add("test", "select name from blah");
    }
    runner.start();
}

function setup(conError, sqlError) {
    QueryQueue.config(config);
    mysql.sqlError = sqlError;
    mysql.conError = conError;
    mysql.expects('createPool').returns({
        getConnection: function (callback) {
            callback(mysql.conError, {
                query: function (query, params, callback) {
                    var err = (mysql.sqlError ? {} : false);
                    callback(err, {});
                }
            });
        },
        releaseConnection: function (connection) {
        },
        end: function (callback) {
            callback && callback();
        }
    }).atLeast(1);
}

function tearDown() {
    QueryQueue.reset();
}

describe('QueryQueue', function () {<commit_msg>Cleanup tests Increased queries and runners<commit_after>'use strict';

const sinon = require('sinon');
var expect = require('chai').expect;
var QueryQueue = require('../queryqueue');
var before = require("mocha").before;
var after = require("mocha").after;
var mysql = sinon.mock(require('mysql'));

var config = {
    host: "localhost",
    user: "user",
    password: "password",
    database: "database"
};

function manyRunners(expected) {
    for (var i = 0; i < 100; i++) {
        singleRunner(expected);
    }
}

function singleRunner(expected) {
    var runner = QueryQueue.Runner(function (result, success) {
        expect(success).to.equal(expected);
    });
    for (var i = 0; i < 100; i++) {
        runner.add("test", "select name from blah");
    }
    runner.start();
}

function setup(conError, sqlError) {
    QueryQueue.config(config);
    mysql.expects('createPool').returns({
        getConnection: function (callback) {
            callback(conError, {
                query: function (query, params, callback) {
                    var err = (sqlError ? {} : false);
                    callback(err, {});
                }
            });
        },
        releaseConnection: function (connection) {
        },
        end: function (callback) {
            callback && callback();
        }
    }).atLeast(1);
}

function tearDown() {
    QueryQueue.reset();
}

describe('QueryQueue', function () {
{'fraction_non_alphanumeric': 0.15331491712707182, 'fraction_numerical': 0.0055248618784530384, 'mean_word_length': 2.4903614457831327, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '7096814', 'n_tokens_mistral': 857, 'n_tokens_neox': 824, 'n_words': 197}