get the unit tests to pass

This commit is contained in:
spalger
2016-05-19 09:09:31 -07:00
parent 38cf442acc
commit c7f6c09d8c
31 changed files with 67 additions and 75 deletions

View File

@ -78,4 +78,4 @@ grunt.registerTask('mocha_jenkins_integration', function (branch) {
grunt.task.run('mochacov:jenkins_integration');
});
module.exports = config;
module.exports = config;

View File

@ -31,19 +31,19 @@ utils.minorVersion = function (version) {
utils.increaseVersion = function (version, type) {
var i;
switch (type) {
case 'major':
i = 0;
break;
case 'minor':
i = 1;
break;
case 'bug':
case 'patch':
case 'bugfix':
i = 2;
break;
default:
throw new TypeError('unexpected version bump type');
case 'major':
i = 0;
break;
case 'minor':
i = 1;
break;
case 'bug':
case 'patch':
case 'bugfix':
i = 2;
break;
default:
throw new TypeError('unexpected version bump type');
}
// breakout the current version

View File

@ -30,7 +30,7 @@ var format = require('util').format;
var NL_RE = /(\r?\n)/g;
var ROOT = join(__dirname, '..');
var GRUNT = join(ROOT, 'node_modules', '.bin', 'grunt');
var ENV = _.clone(process.env);
var ENV = _v4.clone(process.env);
var JENKINS = !!ENV.JENKINS_HOME;
var TASKS = [];

View File

@ -4,7 +4,6 @@ module.exports = function (branch, done) {
* @type {[type]}
*/
var _ = require('../../src/lib/utils');
var _v4 = require('lodash-migrate/lodash');
var utils = require('../../grunt/utils');
var fs = require('fs');
var async = require('async');

View File

@ -9,7 +9,7 @@ var api = module.exports = {};
api._namespaces = <%= stringify(namespaces) %>;<%
_.each(actions, function (action) {
_v4.each(actions, function (action) {
var namespace = action.location.split('.').shift();
if (_.includes(namespaces, namespace)) {
_.pull(namespaces, namespace);
@ -22,7 +22,7 @@ api.<%= namespace %> = namespace();<%
});
_.each(proxies, function (action) {%>
_v4.each(proxies, function (action) {%>
<%= partials.client_action_proxy(action) %><%
});

View File

@ -2,11 +2,11 @@
* Perform a [<%= name %>](<%= docUrl %>) request
*
* @param {Object} params - An object with parameters used to carry out this action<%
_.each(allParams, function(param, paramName) { %>
_v4.each(allParams, function(param, paramName) { %>
* @param {<%= paramType(param.type) %>} <%= paramWithDefault('params.' + paramName, param.default) %><%
if (param.description) {
%> - <%= param.description %><%
}
%><% }) %>
*/
api<%= (location[0] === '[' ? '' : '.') + location %> = ca(<%= stringify(spec, true) %>);
api<%= (location[0] === '[' ? '' : '.') + location %> = ca(<%= stringify(spec, true) %>);

View File

@ -2,7 +2,7 @@
* Perform a [<%= name %>](<%= docUrl %>) request
*
* @param {Object} params - An object with parameters used to carry out this action<%
_.each(allParams, function(param, paramName) { %>
_v4.each(allParams, function(param, paramName) { %>
* @param {<%= paramType(param.type) %>} <%= paramWithDefault('params.' + paramName, param.default) %><%
if (param.description) {
%> - <%= param.description %><%
@ -16,4 +16,4 @@ if (typeof transformBody === 'string') { %>, {
}
}<%
}
%>);
%>);

View File

@ -1,6 +1,5 @@
var _ = require('../../../src/lib/utils');
var _v4 = require('lodash-migrate/lodash');
var utils = require('../../../grunt/utils');
var fs = require('fs');
var path = require('path');

View File

@ -56,11 +56,11 @@ function Client(config) {
this.transport = new Transport(config);
_.each(EsApiClient.prototype, function (Fn, prop) {
_v4.each(EsApiClient.prototype, _.bind(function (Fn, prop) {
if (Fn.prototype instanceof clientAction.ApiNamespace) {
this[prop] = new Fn(this.transport);
}
}, this);
}, this));
delete this._namespaces;
}
@ -74,9 +74,9 @@ function Client(config) {
var Constructor = EsApiClient;
if (config.plugins) {
Constructor.prototype = _.cloneDeep(Constructor.prototype);
Constructor.prototype = _v4.cloneDeep(Constructor.prototype);
_.each(config.plugins, function (setup) {
_v4.each(config.plugins, function (setup) {
Constructor = setup(Constructor, config, {
apis: require('./apis'),
connectors: require('./connectors'),

View File

@ -57,7 +57,7 @@ function makeFactoryWithModifier(modifier) {
}
try {
return exec(this.transport, spec, _.clone(params), cb);
return exec(this.transport, spec, _v4.clone(params), cb);
} catch (e) {
if (typeof cb === 'function') {
_.nextTick(cb, e);

View File

@ -257,7 +257,7 @@ ConnectionPool.prototype.getConnections = function (status, limit) {
if (limit == null) {
return list.slice(0);
} else {
return _.shuffle(list).slice(0, limit);
return _v4.shuffle(list).slice(0, limit);
}
};
@ -308,7 +308,7 @@ ConnectionPool.prototype.setHosts = function (hosts) {
var i;
var id;
var host;
var toRemove = _.clone(this.index);
var toRemove = _v4.clone(this.index);
for (i = 0; i < hosts.length; i++) {
host = hosts[i];

View File

@ -6,7 +6,7 @@ var opts = {
var _ = require('../utils');
// remove modules that have been ignored by browserify
_.each(opts, function (conn, name) {
_v4.each(opts, function (conn, name) {
if (typeof conn !== 'function') {
delete opts[name];
}

View File

@ -53,7 +53,7 @@ HttpConnector.prototype.onStatusSet = _.handler(function (status) {
var agent = this.agent;
var toRemove = [];
var collectSockets = function (sockets, host) {
_.each(sockets, function (s) {
_v4.each(sockets, function (s) {
if (s) toRemove.push([host, s]);
});
};
@ -61,9 +61,9 @@ HttpConnector.prototype.onStatusSet = _.handler(function (status) {
agent.minSockets = agent.maxSockets = 0;
agent.requests = {};
_.each(agent.sockets, collectSockets);
_.each(agent.freeSockets, collectSockets);
_.each(toRemove, function (args) {
_v4.each(agent.sockets, collectSockets);
_v4.each(agent.freeSockets, collectSockets);
_v4.each(toRemove, function (args) {
var host = args[0], socket = args[1];
agent.removeSocket(socket, host);
socket.destroy();

View File

@ -137,7 +137,7 @@ var statusCodes = [
[510, 'Not Extended']
];
_.each(statusCodes, function createStatusCodeError(tuple) {
_v4.each(statusCodes, function createStatusCodeError(tuple) {
var status = tuple[0];
var names = tuple[1];
var allNames = [].concat(names, status);

View File

@ -46,7 +46,7 @@ Host.defaultPorts = {
};
function Host(config, globalConfig) {
config = _.clone(config || {});
config = _v4.clone(config || {});
globalConfig = globalConfig || {};
// defaults
@ -85,7 +85,7 @@ function Host(config, globalConfig) {
if (_.isObject(config)) {
// move hostname/portname to host/port semi-intelligently.
_.each(simplify, function (to) {
_v4.each(simplify, function (to) {
var from = to + 'name';
if (config[from] && config[to]) {
if (config[to].indexOf(config[from]) === 0) {
@ -107,7 +107,7 @@ function Host(config, globalConfig) {
}
_.forOwn(config, function (val, prop) {
if (val != null) this[prop] = _.clone(val);
if (val != null) this[prop] = _v4.clone(val);
}, this);
// make sure the query string is parsed

View File

@ -176,7 +176,7 @@ Log.parseLevels = function (input) {
* @method join
* @static
* @private
* @param {*} arrayish - An array like object that can be itterated by _.each
* @param {*} arrayish - An array like object that can be itterated by _v4.each
* @return {String} - The final string.
*/
Log.join = function (arrayish) {
@ -289,7 +289,7 @@ Log.normalizeTraceArgs = function (method, requestUrl, body, responseBody, respo
if (typeof requestUrl === 'string') {
requestUrl = url.parse(requestUrl, true, true);
} else {
requestUrl = _.clone(requestUrl);
requestUrl = _v4.clone(requestUrl);
if (requestUrl.path) {
requestUrl.query = url.parse(requestUrl.path, true, false).query;
}

View File

@ -64,7 +64,7 @@ LoggerAbstract.prototype.setupListeners = function (levels) {
this.listeningLevels = [];
_.each(levels, function (level) {
_v4.each(levels, _.bind(function (level) {
var fnName = 'on' + _.ucfirst(level);
if (this.bound[fnName]) {
this.listeningLevels.push(level);
@ -72,7 +72,7 @@ LoggerAbstract.prototype.setupListeners = function (levels) {
} else {
throw new Error('Unable to listen for level "' + level + '"');
}
}, this);
}, this));
};
/**
@ -83,9 +83,9 @@ LoggerAbstract.prototype.setupListeners = function (levels) {
* @return {undefined}
*/
LoggerAbstract.prototype.cleanUpListeners = _.handler(function () {
_.each(this.listeningLevels, function (level) {
_v4.each(this.listeningLevels, _.bind(function (level) {
this.log.removeListener(level, this.bound['on' + _.ucfirst(level)]);
}, this);
}, this));
});
/**

View File

@ -62,7 +62,7 @@ function Transport(config) {
}
if (randomizeHosts) {
hostsConfig = _.shuffle(hostsConfig);
hostsConfig = _v4.shuffle(hostsConfig);
}
self.setHosts(hostsConfig);
@ -439,7 +439,7 @@ Transport.prototype.setHosts = function (hostsConfigs) {
Transport.prototype.close = function () {
this.log.close();
this.closed = true;
_.each(this._timers, clearTimeout);
_v4.each(this._timers, clearTimeout);
this._timers = null;
this.connectionPool.close();
};

View File

@ -32,7 +32,7 @@ utils.joinPath = path.join;
* @return {Object} - returns the modified to value
*/
utils.deepMerge = function (to, from) {
_.each(from, function (fromVal, key) {
_v4.each(from, function (fromVal, key) {
switch (typeof to[key]) {
case 'undefined':
to[key] = from[key];
@ -56,7 +56,7 @@ utils.deepMerge = function (to, from) {
* @param {Array} arr - An array to check
* @return {Boolean}
*/
_.each([
_v4.each([
'String',
'Object',
'PlainObject',
@ -404,7 +404,7 @@ _.getUnwrittenFromStream = function (stream) {
var out = '';
if (!writeBuffer.length) return out;
_.each(writeBuffer, function (writeReq) {
_v4.each(writeBuffer, function (writeReq) {
if (writeReq.chunk) {
// 0.9.12+ uses WriteReq objects with a chunk prop
out += '' + writeReq.chunk;

View File

@ -568,7 +568,7 @@ YamlDoc.prototype = {
// recursively replace all $var within args
_.forOwn(args, function recurse(val, key, lvl) {
if (_.isObject(val)) {
return _.each(val, recurse);
return _v4.each(val, recurse);
}
if (_.isString(val)) {

View File

@ -221,7 +221,7 @@ MockHttpRequest.prototype = {
getAllResponseHeaders: function () {
var r = '';
_.each(this.responseHeaders, function (header) {
_v4.each(this.responseHeaders, function (header) {
if ((header === 'set-cookie') || (header === 'set-cookie2')) {
return;
}
@ -353,7 +353,7 @@ MockHttpRequest.prototype = {
this.responseText = null;
this.error = true;
_.each(this.requestHeaders, function (header) {
_v4.each(this.requestHeaders, function (header) {
delete this.requestHeaders[header];
}, this);

View File

@ -4,7 +4,6 @@ module.exports = function (makeLogger) {
var fs = require('fs');
var once = require('events').EventEmitter.prototype.once;
var _ = require('lodash-migrate');
var _v4 = require('lodash-migrate/lodash');
describe('buffer flush', function () {
if (require('stream').Writable) {

View File

@ -68,7 +68,7 @@ describe('Client Action runner', function () {
afterEach(function () { _stash = {}; });
var make = function (params) {
_stash.orig = params;
_stash.copy = _.clone(params);
_stash.copy = _v4.clone(params);
return params;
};
make.check = function () {

View File

@ -175,10 +175,10 @@ describe('Connection Pool', function () {
new ConnectionAbstract(new Host('http://localhost:9202')),
new ConnectionAbstract(new Host('http://localhost:9203'))
];
var pingQueue = _.shuffle(connections);
var pingQueue = _v4.shuffle(connections);
var expectedSelection = pingQueue[pingQueue.length - 1];
_.each(pingQueue, function (conn) {
_v4.each(pingQueue, function (conn) {
pool.addConnection(conn);
stub(conn, 'ping', function (params, cb) {
if (typeof params === 'function') {

View File

@ -2,7 +2,7 @@ var errors = require('../../../src/lib/errors');
var expect = require('expect.js');
var _ = require('lodash-migrate');
_.each(errors, function (CustomError, name) {
_v4.each(errors, function (CustomError, name) {
if (name.charAt(0) !== '_') {
describe(name, function () {
it('extend the ErrorAbstract and Error classes', function () {

View File

@ -3,7 +3,6 @@ describe('File Logger', function () {
var FileLogger = require('../../../src/lib/loggers/file');
var once = require('events').EventEmitter.prototype.once;
var _ = require('../../../src/lib/utils');
var _v4 = require('lodash-migrate/lodash');
var parentLog;
var logger;
var expect = require('expect.js');

View File

@ -1,7 +1,6 @@
describe('Random Selector', function () {
var randomSelector = require('../../../src/lib/selectors/random');
var _ = require('lodash-migrate');
var _v4 = require('lodash-migrate/lodash');
var expect = require('expect.js');
it('chooses a selection by random', function () {

View File

@ -1,12 +1,11 @@
describe('Round Robin Selector', function () {
var selector = require('../../../src/lib/selectors/round_robin');
var _ = require('lodash-migrate');
var _v4 = require('lodash-migrate/lodash');
var expect = require('expect.js');
it('chooses options in order', function () {
var options = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
var expected = _.clone(options);
var expected = _v4.clone(options);
var selections = [];
_v4.times(options.length, function () {

View File

@ -5,7 +5,6 @@ describe('Stream Logger', function () {
var once = require('events').EventEmitter.prototype.once;
var stream = new MockWritableStream();
var _ = require('../../../src/lib/utils');
var _v4 = require('lodash-migrate/lodash');
var expect = require('expect.js');
var parentLog;

View File

@ -5,7 +5,6 @@ var errors = require('../../../src/lib/errors');
var sinon = require('sinon');
var expect = require('expect.js');
var _ = require('lodash-migrate');
var _v4 = require('lodash-migrate/lodash');
var nodeList = require('../../fixtures/short_node_list.json');
var stub = require('../../utils/auto_release_stub').make();
@ -288,23 +287,23 @@ describe('Transport Class', function () {
it('calls _.shuffle be default', function () {
var _ = require('../../../src/lib/utils');
stub(Transport.connectionPools.main.prototype, 'setHosts');
stub(_, 'shuffle');
stub(_v4, 'shuffle');
var trans = new Transport({
hosts: 'localhost'
});
expect(_.shuffle.callCount).to.eql(1);
expect(_v4.shuffle.callCount).to.eql(1);
});
it('skips the call to _.shuffle when false', function () {
var _ = require('../../../src/lib/utils');
stub(Transport.connectionPools.main.prototype, 'setHosts');
stub(_, 'shuffle');
stub(_v4, 'shuffle');
var trans = new Transport({
hosts: 'localhost',
randomizeHosts: false
});
expect(_.shuffle.callCount).to.eql(0);
expect(_v4.shuffle.callCount).to.eql(0);
});
});
});
@ -619,7 +618,7 @@ describe('Transport Class', function () {
// trigger a select so that we can harvest the connection list
trans.connectionPool.select(_.noop);
_.each(connections, function (conn) {
_v4.each(connections, function (conn) {
stub(conn, 'request', failRequest);
});
@ -763,7 +762,7 @@ describe('Transport Class', function () {
prom.then(_.noop, _.noop);
expect(_.size(clock.timers)).to.eql(1);
_.each(clock.timers, function (timer, id) {
_v4.each(clock.timers, function (timer, id) {
expect(timer.callAt).to.eql(30000);
clearTimeout(id);
});
@ -780,14 +779,14 @@ describe('Transport Class', function () {
prom.then(_.noop, _.noop);
expect(_.size(clock.timers)).to.eql(1);
_.each(clock.timers, function (timer, id) {
_v4.each(clock.timers, function (timer, id) {
expect(timer.callAt).to.eql(5000);
clearTimeout(id);
});
});
_.each([false, 0, null], function (falsy) {
_v4.each([false, 0, null], function (falsy) {
it('skips the timeout when it is ' + falsy, function () {
var clock = sinon.useFakeTimers();
stub.autoRelease(clock);

View File

@ -32,7 +32,7 @@ var _ = require('lodash-migrate');
var chalk = require('chalk');
function makeJUnitXml(runnerName, testDetails) {
_.each(testDetails.suites, function serializeSuite(suiteInfo) {
_v4.each(testDetails.suites, function serializeSuite(suiteInfo) {
var suite = suites.ele('testsuite', {
package: 'elasticsearch-js',
@ -46,7 +46,7 @@ function makeJUnitXml(runnerName, testDetails) {
time: suiteInfo.time / 1000
});
_.each(suiteInfo.results, function (testInfo) {
_v4.each(suiteInfo.results, function (testInfo) {
var section;
var integration = false;
@ -83,7 +83,7 @@ function makeJUnitXml(runnerName, testDetails) {
});
if (suiteInfo.suites) {
_.each(suiteInfo.suites, serializeSuite);
_v4.each(suiteInfo.suites, serializeSuite);
}
giveOutput(suite, suiteInfo);