Merging spenceralger:travis_and_coveralls. Summary of changes:

- removed several unneeded devDeps
- removed old get_spec.js script
- the client's ping method will now send back true as the body when the ping
  succceeds, and false when it does not. When the ping fails, the error will
  still be sent back and the connection's status will still be set to "dead".
- All of the client's methods now have a spec property, which will provide the
  JSON spec used to run that method.
- The yaml test runner will only camelCase param names that are documented, uses
  the client's method's new spec property
- Trace log events will now have their proper original query string parameters
- The "tracer" logger will now write to elasticsearch-tracer.log by default, and
  will truncate the file if it already exists.
- When running the integration tests, the client will now use a tracer logger which
  writes to stderr. The default level is "warning", but with the VERBOSE environment
  var it becomes "trace" and the logger will write to it's default file
- Added .idea to the .gitignore, it was being published to NPM
- Cleanup of the grunt tasks. Consilidated several tiny files into seperate moderately sized ones.
This commit is contained in:
Spencer Alger
2013-12-18 13:21:40 -07:00
parent 4c3bd0080d
commit 96b44ebf8b
25 changed files with 199 additions and 229 deletions

View File

@ -8,8 +8,8 @@
module.exports = YamlDoc;
var _ = require('../../../src/lib/utils');
var should = require('should');
var clientManager = require('./client_manager');
var expect = require('expect.js');
/**
* The version that ES is running, in comparable string form XXX-XXX-XXX, fetched when needed
@ -42,7 +42,7 @@ function getVersionFromES(done) {
if (err) {
throw new Error('unable to get info about ES');
}
expect(resp.version.number).to.match(versionRE);
should(resp.version.number).match(versionRE);
ES_VERSION = versionToComparableString(versionRE.exec(resp.version.number)[1]);
done();
});
@ -77,7 +77,7 @@ function versionToComparableString(version) {
*/
function rangeMatchesCurrentVersion(rangeString, done) {
function doWork() {
expect(rangeString).to.match(versionRangeRE);
should(rangeString).match(versionRangeRE);
var range = versionRangeRE.exec(rangeString);
range = _.map(_.last(range, 2), versionToComparableString);
@ -114,7 +114,7 @@ function YamlDoc(doc, file) {
var method = self['do_' + action.name];
// check that it's a function
expect(method).to.be.a('function');
should(method).have.type('function');
if (_.isPlainObject(action.args)) {
action.name += ' ' + _.keys(action.args).join(', ');
@ -306,11 +306,18 @@ YamlDoc.prototype = {
var action = Object.keys(args).pop();
var clientActionName = _.map(action.split('.'), _.camelCase).join('.');
var clientAction = this.get(clientActionName, client);
var params = _.transform(args[action], function (note, val, name) {
note[_.camelCase(name)] = (typeof val === 'string' && val[0] === '$') ? this.get(val) : val;
var params = _.transform(args[action], function (params, val, name) {
var camelName = _.camelCase(name);
// undocumented params should be passed through as-is
var paramName = name;
if (clientAction && clientAction.spec && clientAction.spec.params && clientAction.spec.params[camelName]) {
paramName = camelName;
}
params[paramName] = (typeof val === 'string' && val[0] === '$') ? this.get(val) : val;
}, {}, this);
expect(clientAction || clientActionName).to.be.a('function');
should(clientAction || clientActionName).have.type('function');
if (typeof clientAction === 'function') {
if (_.isNumeric(catcher)) {
@ -325,11 +332,11 @@ YamlDoc.prototype = {
if (catcher) {
if (catcher instanceof RegExp) {
// error message should match the regexp
expect(error.message).to.match(catcher);
should(error.message).match(catcher);
error = null;
} else if (typeof catcher === 'function') {
// error should be an instance of
expect(error).to.be.a(catcher);
should(error).be.an.instanceOf(catcher);
error = null;
} else {
return done(new Error('Invalid catcher ' + catcher));
@ -373,7 +380,7 @@ YamlDoc.prototype = {
* @return {undefined}
*/
do_is_true: function (path) {
expect(this.get(path)).to.be.ok;
should(Boolean(this.get(path))).equal(true, 'path: ' + path);
},
/**
@ -384,7 +391,7 @@ YamlDoc.prototype = {
* @return {undefined}
*/
do_is_false: function (path) {
expect(this.get(path)).to.not.be.ok;
should(Boolean(this.get(path))).equal(false, 'path: ' + path);
},
/**
@ -398,7 +405,7 @@ YamlDoc.prototype = {
if (val[0] === '$') {
val = this.get(val);
}
expect(this.get(path)).to.eql(val);
should(this.get(path)).eql(val, 'path: ' + path);
}, this);
},
@ -410,7 +417,7 @@ YamlDoc.prototype = {
*/
do_lt: function (args) {
_.forOwn(args, function (num, path) {
expect(this.get(path)).to.be.below(num);
should(this.get(path)).be.below(num, 'path: ' + path);
}, this);
},
@ -422,7 +429,7 @@ YamlDoc.prototype = {
*/
do_gt: function (args) {
_.forOwn(args, function (num, path) {
expect(this.get(path)).to.be.above(num);
should(this.get(path)).be.above(num, 'path: ' + path);
}, this);
},
@ -435,7 +442,7 @@ YamlDoc.prototype = {
*/
do_length: function (args) {
_.forOwn(args, function (len, path) {
expect(_.size(this.get(path))).to.be(len);
should(_.size(this.get(path))).eql(len, 'path: ' + path);
}, this);
}
};