[eslint] fix no-unused-vars violations
This commit is contained in:
@ -29,7 +29,7 @@ rules:
|
||||
no-undef: warn
|
||||
no-underscore-dangle: off
|
||||
no-unused-expressions: error
|
||||
no-unused-vars: warn
|
||||
no-unused-vars: error
|
||||
no-use-before-define: off
|
||||
object-shorthand: off
|
||||
one-var: off
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
module.exports = function (branch) {
|
||||
var path = require('path');
|
||||
var jsYaml = require('js-yaml');
|
||||
var YamlFile = require('./yaml_file');
|
||||
var root = require('find-root')(__dirname);
|
||||
var rootReq = function (loc) { return require(path.join(root, loc)); };
|
||||
var _ = require('lodash');
|
||||
var utils = rootReq('src/lib/utils');
|
||||
var gruntUtils = rootReq('grunt/utils');
|
||||
var es = rootReq('src/elasticsearch');
|
||||
var clientManager = require('./client_manager');
|
||||
|
||||
var port = parseInt(process.env.ES_PORT || 9200, 10);
|
||||
@ -33,7 +30,7 @@ module.exports = function (branch) {
|
||||
return clientManager.get().clearEs();
|
||||
});
|
||||
|
||||
var files = _.map(require('./yaml_tests_' + utils.snakeCase(branch) + '.json'), function (docs, filename) {
|
||||
_.map(require('./yaml_tests_' + utils.snakeCase(branch) + '.json'), function (docs, filename) {
|
||||
return new YamlFile(filename, docs);
|
||||
});
|
||||
|
||||
|
||||
@ -13,19 +13,19 @@ if (Writable) {
|
||||
MockWritableStream = module.exports = function (opts) {
|
||||
Writable.call(this, opts);
|
||||
|
||||
this._write = function (chunk, encoding, cb) {};
|
||||
this._write = function () {};
|
||||
};
|
||||
util.inherits(MockWritableStream, Writable);
|
||||
} else {
|
||||
// Node < 0.10 did not provide a usefull stream abstract
|
||||
var Stream = require('stream').Stream;
|
||||
module.exports = MockWritableStream = function (opts) {
|
||||
module.exports = MockWritableStream = function () {
|
||||
Stream.call(this);
|
||||
this.writable = true;
|
||||
};
|
||||
util.inherits(MockWritableStream, Stream);
|
||||
|
||||
MockWritableStream.prototype.write = function (data) {
|
||||
MockWritableStream.prototype.write = function () {
|
||||
if (!this.writable) {
|
||||
this.emit('error', new Error('stream not writable'));
|
||||
return false;
|
||||
@ -41,15 +41,15 @@ if (Writable) {
|
||||
}
|
||||
};
|
||||
|
||||
MockWritableStream.prototype.end = function (data, encoding, cb) {
|
||||
if (typeof(data) === 'function') {
|
||||
cb = data;
|
||||
} else if (typeof(encoding) === 'function') {
|
||||
cb = encoding;
|
||||
MockWritableStream.prototype.end = function (data, encoding) {
|
||||
if (typeof data === 'function') {
|
||||
// no callback support
|
||||
} else if (typeof encoding === 'function') {
|
||||
this.write(data);
|
||||
} else if (arguments.length > 0) {
|
||||
this.write(data, encoding);
|
||||
}
|
||||
|
||||
this.writable = false;
|
||||
};
|
||||
|
||||
|
||||
7
test/unit/browser_builds/angular.js
vendored
7
test/unit/browser_builds/angular.js
vendored
@ -2,18 +2,14 @@
|
||||
var _ = require('lodash');
|
||||
var expect = require('expect.js');
|
||||
var Promise = require('bluebird');
|
||||
var sinon = require('sinon');
|
||||
|
||||
describe('Angular esFactory', function () {
|
||||
before(function () {
|
||||
require('../../../src/elasticsearch.angular.js');
|
||||
});
|
||||
|
||||
var uuid = (function () { var i = 0; return function () { return ++i; }; }());
|
||||
var esFactory;
|
||||
var $http;
|
||||
var $rootScope;
|
||||
var $httpBackend;
|
||||
|
||||
function bootstrap(env) {
|
||||
beforeEach(function () {
|
||||
@ -37,10 +33,8 @@ describe('Angular esFactory', function () {
|
||||
});
|
||||
|
||||
beforeEach(angular.mock.inject(function ($injector) {
|
||||
$http = $injector.get('$http');
|
||||
esFactory = $injector.get('esFactory');
|
||||
$rootScope = $injector.get('$rootScope');
|
||||
$httpBackend = $injector.get('$httpBackend');
|
||||
}));
|
||||
}
|
||||
|
||||
@ -70,7 +64,6 @@ describe('Angular esFactory', function () {
|
||||
|
||||
it('returns an error created by calling a method incorrectly', function () {
|
||||
var client = esFactory({ hosts: null });
|
||||
var err;
|
||||
|
||||
var prom = client.get().then(function () {
|
||||
throw new Error('expected request to fail');
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
var expect = require('expect.js');
|
||||
var Transport = require('../../../src/lib/transport');
|
||||
|
||||
describe('elasticsearch namespace', function () {
|
||||
var es = window.elasticsearch;
|
||||
|
||||
1
test/unit/browser_builds/jquery.js
vendored
1
test/unit/browser_builds/jquery.js
vendored
@ -1,6 +1,5 @@
|
||||
/* global $ */
|
||||
var expect = require('expect.js');
|
||||
var Transport = require('../../../src/lib/transport');
|
||||
|
||||
describe('jQuery.es namespace', function () {
|
||||
it('is defined on the global jQuery', function () {
|
||||
|
||||
@ -48,7 +48,7 @@ module.exports = function (makeLogger) {
|
||||
once.call(process, event, handler);
|
||||
});
|
||||
|
||||
var logger = makeLogger();
|
||||
makeLogger();
|
||||
|
||||
expect(function () {
|
||||
// call the event handler
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var blanket = require('blanket')({
|
||||
require('blanket')({
|
||||
pattern: require('path').join(__dirname, '../../src')
|
||||
});
|
||||
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
var expect = require('expect.js');
|
||||
var Log = require('../../src/lib/log');
|
||||
var LoggerAbstract = require('../../src/lib/logger');
|
||||
var TracerLogger = require('../../src/lib/loggers/tracer');
|
||||
var now = new Date('2013-03-01T00:00:00Z');
|
||||
var sinon = require('sinon');
|
||||
|
||||
@ -24,7 +22,7 @@ module.exports = function (makeLogger) {
|
||||
});
|
||||
|
||||
it('listens for the loggers\' "closing" event', function () {
|
||||
var logger = makeLogger(parent);
|
||||
makeLogger(parent);
|
||||
expect(parent.listenerCount('closing')).to.eql(1);
|
||||
});
|
||||
});
|
||||
@ -38,7 +36,7 @@ module.exports = function (makeLogger) {
|
||||
});
|
||||
|
||||
it('listens to just error when log is explicitly error', function () {
|
||||
var logger = makeLogger(parent, 'error');
|
||||
makeLogger(parent, 'error');
|
||||
expect(parent.listenerCount('error')).to.eql(1);
|
||||
expect(parent.listenerCount('warning')).to.eql(0);
|
||||
expect(parent.listenerCount('info')).to.eql(0);
|
||||
@ -47,7 +45,7 @@ module.exports = function (makeLogger) {
|
||||
});
|
||||
|
||||
it('listens for all the events when level is "trace"', function () {
|
||||
var logger = makeLogger(parent, 'trace');
|
||||
makeLogger(parent, 'trace');
|
||||
expect(parent.listenerCount('error')).to.eql(1);
|
||||
expect(parent.listenerCount('warning')).to.eql(1);
|
||||
expect(parent.listenerCount('info')).to.eql(1);
|
||||
@ -56,7 +54,7 @@ module.exports = function (makeLogger) {
|
||||
});
|
||||
|
||||
it('listens for specific events when level is an array', function () {
|
||||
var logger = makeLogger(parent, ['error', 'trace']);
|
||||
makeLogger(parent, ['error', 'trace']);
|
||||
expect(parent.listenerCount('error')).to.eql(1);
|
||||
expect(parent.listenerCount('warning')).to.eql(0);
|
||||
expect(parent.listenerCount('info')).to.eql(0);
|
||||
@ -87,7 +85,7 @@ module.exports = function (makeLogger) {
|
||||
});
|
||||
|
||||
it('emits events because something is listening', function () {
|
||||
var logger = makeLogger(parent, 'trace');
|
||||
makeLogger(parent, 'trace');
|
||||
stub(parent, 'emit');
|
||||
|
||||
parent.error(new Error('error message'));
|
||||
@ -142,7 +140,7 @@ module.exports = function (makeLogger) {
|
||||
describe('#onError', function () {
|
||||
it('uses the Error name when it is not just "Error"', function () {
|
||||
var logger = makeLogger();
|
||||
stub(logger, 'write', function (label, msg) {
|
||||
stub(logger, 'write', function (label) {
|
||||
expect(label).to.eql('TypeError');
|
||||
});
|
||||
|
||||
@ -152,7 +150,7 @@ module.exports = function (makeLogger) {
|
||||
|
||||
it('uses "ERROR" when the error name is "Error"', function () {
|
||||
var logger = makeLogger();
|
||||
stub(logger, 'write', function (label, msg) {
|
||||
stub(logger, 'write', function (label) {
|
||||
expect(label).to.eql('ERROR');
|
||||
});
|
||||
|
||||
@ -164,7 +162,7 @@ module.exports = function (makeLogger) {
|
||||
describe('#onWarning', function () {
|
||||
it('uses the "WARNING" label', function () {
|
||||
var logger = makeLogger();
|
||||
stub(logger, 'write', function (label, msg) {
|
||||
stub(logger, 'write', function (label) {
|
||||
expect(label).to.eql('WARNING');
|
||||
});
|
||||
logger.onWarning('message');
|
||||
@ -185,7 +183,7 @@ module.exports = function (makeLogger) {
|
||||
describe('#onInfo', function () {
|
||||
it('uses the "INFO" label', function () {
|
||||
var logger = makeLogger();
|
||||
stub(logger, 'write', function (label, msg) {
|
||||
stub(logger, 'write', function (label) {
|
||||
expect(label).to.eql('INFO');
|
||||
});
|
||||
logger.onInfo('message');
|
||||
@ -206,7 +204,7 @@ module.exports = function (makeLogger) {
|
||||
describe('#onDebug', function () {
|
||||
it('uses the "DEBUG" label', function () {
|
||||
var logger = makeLogger();
|
||||
stub(logger, 'write', function (label, msg) {
|
||||
stub(logger, 'write', function (label) {
|
||||
expect(label).to.eql('DEBUG');
|
||||
});
|
||||
logger.onDebug('message');
|
||||
@ -227,7 +225,7 @@ module.exports = function (makeLogger) {
|
||||
describe('#onTrace', function () {
|
||||
it('uses the "TRACE" label', function () {
|
||||
var logger = makeLogger();
|
||||
stub(logger, 'write', function (label, msg) {
|
||||
stub(logger, 'write', function (label) {
|
||||
expect(label).to.eql('TRACE');
|
||||
});
|
||||
logger.onTrace(Log.normalizeTraceArgs('GET', 'http://place/thing?me=true', '{}', '{"ok": true}', 200));
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
describe('Logger Abstract', function () {
|
||||
var expect = require('expect.js');
|
||||
var sinon = require('sinon');
|
||||
var Log = require('../../../src/lib/log');
|
||||
var LoggerAbstract = require('../../../src/lib/logger');
|
||||
|
||||
var parentLog;
|
||||
var stub = require('../../utils/auto_release_stub').make();
|
||||
|
||||
function makeLogger(parent, levels) {
|
||||
return new LoggerAbstract(parent || parentLog, {
|
||||
|
||||
@ -92,7 +92,7 @@ describe('Client Action runner', function () {
|
||||
|
||||
describe('clientAction::proxy', function () {
|
||||
it('proxies to the passed function', function () {
|
||||
var action = makeClientActionProxy(function (params, cb) {
|
||||
var action = makeClientActionProxy(function () {
|
||||
throw new Error('proxy function called');
|
||||
});
|
||||
|
||||
@ -110,7 +110,7 @@ describe('Client Action runner', function () {
|
||||
});
|
||||
});
|
||||
|
||||
action({}, function (err, params) {
|
||||
action({}, function () {
|
||||
expect(client.transport.request).to.be.a('function');
|
||||
done();
|
||||
});
|
||||
@ -126,7 +126,7 @@ describe('Client Action runner', function () {
|
||||
});
|
||||
|
||||
it('supports a param transformation function', function () {
|
||||
var action = makeClientActionProxy(function (params, cb) {
|
||||
var action = makeClientActionProxy(function (params) {
|
||||
expect(params).to.have.property('transformed');
|
||||
}, {
|
||||
transform: function (params) {
|
||||
@ -139,7 +139,7 @@ describe('Client Action runner', function () {
|
||||
|
||||
it('returns the proxied function\'s return value', function () {
|
||||
var football = {};
|
||||
var action = makeClientActionProxy(function (params, cb) {
|
||||
var action = makeClientActionProxy(function () {
|
||||
return football;
|
||||
});
|
||||
|
||||
@ -186,7 +186,7 @@ describe('Client Action runner', function () {
|
||||
it('rejects date values', function (done) {
|
||||
action({
|
||||
one: new Date()
|
||||
}, function (err, params) {
|
||||
}, function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
done();
|
||||
});
|
||||
@ -196,7 +196,7 @@ describe('Client Action runner', function () {
|
||||
action({
|
||||
one: ['one'],
|
||||
two: [1304]
|
||||
}, function (err, params) {
|
||||
}, function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
done();
|
||||
});
|
||||
@ -205,7 +205,7 @@ describe('Client Action runner', function () {
|
||||
it('rejects object', function (done) {
|
||||
action({
|
||||
one: { but: 'duration' }
|
||||
}, function (err, params) {
|
||||
}, function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
done();
|
||||
});
|
||||
@ -242,7 +242,7 @@ describe('Client Action runner', function () {
|
||||
it('it rejects regexp', function (done) {
|
||||
action({
|
||||
one: /regexp!/g
|
||||
}, function (err, params) {
|
||||
}, function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
done();
|
||||
});
|
||||
@ -253,7 +253,7 @@ describe('Client Action runner', function () {
|
||||
one: {
|
||||
pasta: 'sauce'
|
||||
}
|
||||
}, function (err, params) {
|
||||
}, function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
done();
|
||||
});
|
||||
@ -302,7 +302,7 @@ describe('Client Action runner', function () {
|
||||
it('it rejects things not in the list', function (done) {
|
||||
action({
|
||||
one: 'not an opt'
|
||||
}, function (err, params) {
|
||||
}, function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
done();
|
||||
});
|
||||
@ -417,7 +417,7 @@ describe('Client Action runner', function () {
|
||||
it('rejects dates', function (done) {
|
||||
action({
|
||||
one: new Date()
|
||||
}, function (err, params) {
|
||||
}, function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
done();
|
||||
});
|
||||
@ -426,7 +426,7 @@ describe('Client Action runner', function () {
|
||||
it('rejects objects', function (done) {
|
||||
action({
|
||||
one: {}
|
||||
}, function (err, params) {
|
||||
}, function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
done();
|
||||
});
|
||||
@ -435,7 +435,7 @@ describe('Client Action runner', function () {
|
||||
it('rejects arrays', function (done) {
|
||||
action({
|
||||
one: []
|
||||
}, function (err, params) {
|
||||
}, function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
done();
|
||||
});
|
||||
@ -444,7 +444,7 @@ describe('Client Action runner', function () {
|
||||
it('rejects regexp', function (done) {
|
||||
action({
|
||||
one: /pasta/g
|
||||
}, function (err, params) {
|
||||
}, function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
done();
|
||||
});
|
||||
@ -488,7 +488,7 @@ describe('Client Action runner', function () {
|
||||
it('rejects dates', function (done) {
|
||||
action({
|
||||
one: new Date()
|
||||
}, function (err, params) {
|
||||
}, function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
done();
|
||||
});
|
||||
@ -497,7 +497,7 @@ describe('Client Action runner', function () {
|
||||
it('rejects objects', function (done) {
|
||||
action({
|
||||
one: {}
|
||||
}, function (err, params) {
|
||||
}, function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
done();
|
||||
});
|
||||
@ -506,7 +506,7 @@ describe('Client Action runner', function () {
|
||||
it('rejects arrays', function (done) {
|
||||
action({
|
||||
one: []
|
||||
}, function (err, params) {
|
||||
}, function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
done();
|
||||
});
|
||||
@ -515,7 +515,7 @@ describe('Client Action runner', function () {
|
||||
it('rejects regexp', function (done) {
|
||||
action({
|
||||
one: /pasta/g
|
||||
}, function (err, params) {
|
||||
}, function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
done();
|
||||
});
|
||||
@ -559,7 +559,7 @@ describe('Client Action runner', function () {
|
||||
it('rejects objects', function (done) {
|
||||
action({
|
||||
one: {}
|
||||
}, function (err, params) {
|
||||
}, function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
done();
|
||||
});
|
||||
@ -568,7 +568,7 @@ describe('Client Action runner', function () {
|
||||
it('rejects arrays', function (done) {
|
||||
action({
|
||||
one: []
|
||||
}, function (err, params) {
|
||||
}, function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
done();
|
||||
});
|
||||
@ -577,7 +577,7 @@ describe('Client Action runner', function () {
|
||||
it('rejects regexp', function (done) {
|
||||
action({
|
||||
one: /pasta/g
|
||||
}, function (err, params) {
|
||||
}, function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
done();
|
||||
});
|
||||
@ -732,7 +732,7 @@ describe('Client Action runner', function () {
|
||||
it('rejects a url if it required params that are not present', function (done) {
|
||||
action(params({
|
||||
type: ['type1', 'type2']
|
||||
}), function (err, resp) {
|
||||
}), function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
params.check();
|
||||
done();
|
||||
@ -845,7 +845,7 @@ describe('Client Action runner', function () {
|
||||
it('enforces required params', function (done) {
|
||||
action(params({
|
||||
b: '3w'
|
||||
}), function (err, resp) {
|
||||
}), function (err) {
|
||||
expect(err).to.be.a(TypeError);
|
||||
params.check();
|
||||
done();
|
||||
|
||||
@ -17,11 +17,13 @@ describe('Connection Abstract', function () {
|
||||
|
||||
it('requires a valid host', function () {
|
||||
expect(function () {
|
||||
var conn = new ConnectionAbstract();
|
||||
// eslint-disable-next-line no-new
|
||||
new ConnectionAbstract();
|
||||
}).to.throwError(TypeError);
|
||||
|
||||
expect(function () {
|
||||
var conn = new ConnectionAbstract({});
|
||||
// eslint-disable-next-line no-new
|
||||
new ConnectionAbstract({});
|
||||
}).to.throwError(TypeError);
|
||||
});
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ function makeLogger(parent, levels) {
|
||||
return new ConsoleLogger(parent, config);
|
||||
}
|
||||
|
||||
var stub = require('../../utils/auto_release_stub').make();
|
||||
require('../../utils/auto_release_stub').make();
|
||||
|
||||
describe('Console Logger', function () {
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ describe('File Logger', function () {
|
||||
once.call(process, event, handler);
|
||||
});
|
||||
|
||||
var logger = makeLogger();
|
||||
makeLogger();
|
||||
|
||||
expect(function () {
|
||||
// call the event handler
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
var Host = require('../../../src/lib/host');
|
||||
var _ = require('lodash');
|
||||
var expect = require('expect.js');
|
||||
var url = require('url');
|
||||
var expectSubObject = require('../../utils/expect_sub_object');
|
||||
|
||||
@ -3,15 +3,12 @@ describe('Http Connector', function () {
|
||||
var _ = require('lodash');
|
||||
var expect = require('expect.js');
|
||||
var nock = require('nock');
|
||||
var sinon = require('sinon');
|
||||
var util = require('util');
|
||||
var parseUrl = require('url').parse;
|
||||
var http = require('http');
|
||||
var https = require('https');
|
||||
var AgentKeepAlive = require('agentkeepalive');
|
||||
|
||||
var Host = require('../../../src/lib/host');
|
||||
var errors = require('../../../src/lib/errors');
|
||||
var HttpConnection = require('../../../src/lib/connectors/http');
|
||||
var ConnectionAbstract = require('../../../src/lib/connection');
|
||||
|
||||
@ -62,7 +59,8 @@ describe('Http Connector', function () {
|
||||
|
||||
it('expects the host to have a protocol of http or https', function () {
|
||||
expect(function () {
|
||||
var con = new HttpConnection(new Host('thrifty://es.com/stuff'));
|
||||
// eslint-disable-next-line no-new
|
||||
new HttpConnection(new Host('thrifty://es.com/stuff'));
|
||||
}).to.throwError(/invalid protocol/i);
|
||||
});
|
||||
|
||||
@ -254,7 +252,7 @@ describe('Http Connector', function () {
|
||||
stub(con.log, 'error');
|
||||
stub(https, 'request', makeStubReqWithMsgWhichErrorsMidBody());
|
||||
|
||||
con.request({}, function (err, resp, status) {
|
||||
con.request({}, function () {
|
||||
expect(con.log.error.callCount).to.eql(0);
|
||||
done();
|
||||
});
|
||||
@ -264,7 +262,7 @@ describe('Http Connector', function () {
|
||||
var con = new HttpConnection(new Host('https://google.com'));
|
||||
stub(https, 'request', makeStubReqWithMsgWhichErrorsMidBody(new Error('no more message :(')));
|
||||
|
||||
con.request({}, function (err, resp, status) {
|
||||
con.request({}, function (err) {
|
||||
expect(err).to.be.an(Error);
|
||||
expect(err.message).to.eql('no more message :(');
|
||||
done();
|
||||
@ -275,7 +273,7 @@ describe('Http Connector', function () {
|
||||
var con = new HttpConnection(new Host('https://google.com'));
|
||||
stub(https, 'request', makeStubReqWithMsgWhichErrorsMidBody());
|
||||
|
||||
con.request({}, function (err, resp, status) {
|
||||
con.request({}, function (err, resp) {
|
||||
expect(resp).to.be(undefined);
|
||||
done();
|
||||
});
|
||||
@ -414,7 +412,7 @@ describe('Http Connector', function () {
|
||||
stub(http.ClientRequest.prototype, 'setNoDelay');
|
||||
var server = nock('http://localhost').get('/').reply(200);
|
||||
|
||||
con.request({}, function (err, resp, status) {
|
||||
con.request({}, function () {
|
||||
expect(http.ClientRequest.prototype.setNoDelay.callCount).to.eql(1);
|
||||
expect(http.ClientRequest.prototype.setNoDelay.lastCall.args[0]).to.eql(true);
|
||||
server.done();
|
||||
@ -433,7 +431,7 @@ describe('Http Connector', function () {
|
||||
|
||||
con.request({
|
||||
body: body
|
||||
}, function (err, resp, status) {
|
||||
}, function () {
|
||||
expect(http.ClientRequest.prototype.setHeader.args.find((arg) => arg[0] === 'Content-Length')).to.eql(['Content-Length', 14]);
|
||||
server.done();
|
||||
done();
|
||||
@ -452,7 +450,7 @@ describe('Http Connector', function () {
|
||||
.once()
|
||||
.reply(200, respBody);
|
||||
|
||||
con.request({}, function (err, resp, status) {
|
||||
con.request({}, function (err, resp) {
|
||||
expect(resp).to.be(respBody);
|
||||
server.done();
|
||||
done();
|
||||
@ -468,7 +466,7 @@ describe('Http Connector', function () {
|
||||
.once()
|
||||
.reply(200, respBody);
|
||||
|
||||
con.request({}, function (err, resp, status) {
|
||||
con.request({}, function (err, resp) {
|
||||
expect(resp).to.be(respBody);
|
||||
server.done();
|
||||
done();
|
||||
|
||||
@ -134,7 +134,7 @@ describe('Log class', function () {
|
||||
log = new Log({
|
||||
log: [
|
||||
{
|
||||
type: function (log, config) {
|
||||
type: function (log) {
|
||||
log.on('error', _.noop);
|
||||
log.on('warning', _.noop);
|
||||
log.on('info', _.noop);
|
||||
@ -237,22 +237,28 @@ describe('Log class', function () {
|
||||
|
||||
it('rejects numbers and other truthy data-types', function () {
|
||||
expect(function () {
|
||||
var log = new Log({ log: 1515 });
|
||||
// eslint-disable-next-line no-new
|
||||
new Log({ log: 1515 });
|
||||
}).to.throwError(/invalid logging output config/i);
|
||||
expect(function () {
|
||||
var log = new Log({ log: /regexp/ });
|
||||
// eslint-disable-next-line no-new
|
||||
new Log({ log: /regexp/ });
|
||||
}).to.throwError(/invalid logging output config/i);
|
||||
expect(function () {
|
||||
var log = new Log({ log: new Date() });
|
||||
// eslint-disable-next-line no-new
|
||||
new Log({ log: new Date() });
|
||||
}).to.throwError(/invalid logging output config/i);
|
||||
expect(function () {
|
||||
var log = new Log({ log: [1515] });
|
||||
// eslint-disable-next-line no-new
|
||||
new Log({ log: [1515] });
|
||||
}).to.throwError(/invalid logging output config/i);
|
||||
expect(function () {
|
||||
var log = new Log({ log: [/regexp/] });
|
||||
// eslint-disable-next-line no-new
|
||||
new Log({ log: [/regexp/] });
|
||||
}).to.throwError(/invalid logging output config/i);
|
||||
expect(function () {
|
||||
var log = new Log({ log: [new Date()] });
|
||||
// eslint-disable-next-line no-new
|
||||
new Log({ log: [new Date()] });
|
||||
}).to.throwError(/invalid logging output config/i);
|
||||
});
|
||||
});
|
||||
|
||||
@ -31,7 +31,6 @@ describe('Stdio Logger', function () {
|
||||
var now = '2013-01-01T00:00:00Z';
|
||||
var nowDate = new Date(now);
|
||||
var nowTime = nowDate.getTime();
|
||||
var clock;
|
||||
|
||||
beforeEach(function () {
|
||||
stub.autoRelease(sinon.useFakeTimers(nowTime));
|
||||
|
||||
@ -78,7 +78,7 @@ describe('Stream Logger', function () {
|
||||
once.call(process, event, handler);
|
||||
});
|
||||
|
||||
var logger = makeLogger();
|
||||
makeLogger();
|
||||
|
||||
expect(function () {
|
||||
// call the event handler
|
||||
|
||||
@ -2,7 +2,6 @@ describe('Tracer Logger', function () {
|
||||
|
||||
var Log = require('../../../src/lib/log');
|
||||
var TracerLogger = require('../../../src/lib/loggers/tracer');
|
||||
var sinon = require('sinon');
|
||||
var expect = require('expect.js');
|
||||
var parentLog;
|
||||
|
||||
|
||||
@ -59,7 +59,8 @@ describe('Transport Class', function () {
|
||||
|
||||
it('Throws an error when connectionPool config is set wrong', function () {
|
||||
expect(function () {
|
||||
var trans = new Transport({
|
||||
// eslint-disable-next-line no-new
|
||||
new Transport({
|
||||
connectionPool: 'pasta'
|
||||
});
|
||||
}).to.throwError(/invalid connectionpool/i);
|
||||
@ -166,7 +167,8 @@ describe('Transport Class', function () {
|
||||
describe('host config', function () {
|
||||
it('rejects non-strings/objects', function () {
|
||||
expect(function () {
|
||||
var trans = new Transport({
|
||||
// eslint-disable-next-line no-new
|
||||
new Transport({
|
||||
host: [
|
||||
'localhost',
|
||||
9393
|
||||
@ -175,7 +177,8 @@ describe('Transport Class', function () {
|
||||
}).to.throwError(TypeError);
|
||||
|
||||
expect(function () {
|
||||
var trans = new Transport({
|
||||
// eslint-disable-next-line no-new
|
||||
new Transport({
|
||||
host: [
|
||||
[9292]
|
||||
]
|
||||
@ -287,7 +290,8 @@ describe('Transport Class', function () {
|
||||
it('calls _.shuffle be default', function () {
|
||||
stub(Transport.connectionPools.main.prototype, 'setHosts');
|
||||
stub(_, 'shuffle');
|
||||
var trans = new Transport({
|
||||
// eslint-disable-next-line no-new
|
||||
new Transport({
|
||||
hosts: 'localhost'
|
||||
});
|
||||
|
||||
@ -296,7 +300,8 @@ describe('Transport Class', function () {
|
||||
it('skips the call to _.shuffle when false', function () {
|
||||
stub(Transport.connectionPools.main.prototype, 'setHosts');
|
||||
stub(_, 'shuffle');
|
||||
var trans = new Transport({
|
||||
// eslint-disable-next-line no-new
|
||||
new Transport({
|
||||
hosts: 'localhost',
|
||||
randomizeHosts: false
|
||||
});
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
var Transport = require('../../../src/lib/transport');
|
||||
var ConnectionPool = require('../../../src/lib/connection_pool');
|
||||
var Host = require('../../../src/lib/host');
|
||||
var errors = require('../../../src/lib/errors');
|
||||
var expect = require('expect.js');
|
||||
|
||||
@ -10,21 +9,6 @@ var through2 = require('through2');
|
||||
var _ = require('lodash');
|
||||
var stub = require('../../utils/auto_release_stub').make();
|
||||
|
||||
/**
|
||||
* Allows the tests call #request() without it doing anything past trying to select
|
||||
* a connection.
|
||||
* @param {Transport} tran - the transport to neuter
|
||||
*/
|
||||
function shortCircuitRequest(tran, delay) {
|
||||
stub(tran.connectionPool, 'select', function (cb) {
|
||||
setTimeout(cb, delay);
|
||||
});
|
||||
}
|
||||
|
||||
function getConnection(transport, status) {
|
||||
return transport.connectionPool.getConnections(status || 'alive', 1).pop();
|
||||
}
|
||||
|
||||
describe('Transport + Mock server', function () {
|
||||
describe('#request', function () {
|
||||
describe('server responds', function () {
|
||||
@ -209,7 +193,7 @@ describe('Transport + Mock server', function () {
|
||||
|
||||
trans.request({
|
||||
path: '/',
|
||||
}, function (err, body, status) {
|
||||
}, function (err, body) {
|
||||
expect(err).to.be(undefined);
|
||||
expect(body).to.eql({
|
||||
'the answer': 42
|
||||
@ -228,7 +212,7 @@ describe('Transport + Mock server', function () {
|
||||
|
||||
trans.request({
|
||||
path: '/hottie-threads',
|
||||
}, function (err, body, status) {
|
||||
}, function (err, body) {
|
||||
expect(err).to.be(undefined);
|
||||
expect(body).to.match(/s?he said/g);
|
||||
done();
|
||||
@ -239,7 +223,7 @@ describe('Transport + Mock server', function () {
|
||||
|
||||
describe('return value', function () {
|
||||
it('resolves the promise it with the response body', function (done) {
|
||||
var serverMock = nock('http://esbox.1.com')
|
||||
nock('http://esbox.1.com')
|
||||
.get('/')
|
||||
.reply(200, {
|
||||
good: 'day'
|
||||
@ -266,7 +250,7 @@ describe('Transport + Mock server', function () {
|
||||
host: 'http://localhost:9200'
|
||||
});
|
||||
|
||||
var server = nock('http://localhost:9200')
|
||||
nock('http://localhost:9200')
|
||||
.get('/')
|
||||
.reply(200, {
|
||||
i: 'am here'
|
||||
@ -286,7 +270,7 @@ describe('Transport + Mock server', function () {
|
||||
host: 'http://localhost:9200'
|
||||
});
|
||||
|
||||
var server = nock('http://localhost:9200')
|
||||
nock('http://localhost:9200')
|
||||
.get('/')
|
||||
.delay(1000)
|
||||
.reply(200, {
|
||||
@ -295,7 +279,7 @@ describe('Transport + Mock server', function () {
|
||||
|
||||
tran.request({
|
||||
requestTimeout: 25
|
||||
}, function (err, resp, status) {
|
||||
}, function (err) {
|
||||
expect(err).to.be.a(errors.RequestTimeout);
|
||||
done();
|
||||
});
|
||||
@ -307,7 +291,7 @@ describe('Transport + Mock server', function () {
|
||||
var clock = sinon.useFakeTimers('setTimeout');
|
||||
stub.autoRelease(clock);
|
||||
|
||||
var serverMock = nock('http://esbox.1.com')
|
||||
nock('http://esbox.1.com')
|
||||
.get('/')
|
||||
.reply(200, function () {
|
||||
var str = through2(function (chunk, enc, cb) {
|
||||
@ -338,7 +322,7 @@ describe('Transport + Mock server', function () {
|
||||
.then(function () {
|
||||
throw new Error('expected the request to fail');
|
||||
})
|
||||
.catch(function (err) {
|
||||
.catch(function () {
|
||||
expect(ConnectionPool.prototype._onConnectionDied.callCount).to.eql(1);
|
||||
expect(tran.sniff.callCount).to.eql(0);
|
||||
expect(_.size(clock.timers)).to.eql(1);
|
||||
|
||||
Reference in New Issue
Block a user