added features parsing and lte/gte methods

This commit is contained in:
Spencer Alger
2014-03-27 11:13:58 -07:00
parent d55be748fd
commit 222598a235

View File

@ -11,6 +11,8 @@ var _ = require('../../../src/lib/utils');
var expect = require('expect.js'); var expect = require('expect.js');
var clientManager = require('./client_manager'); var clientManager = require('./client_manager');
var implementedFeatures = ['gtelte', 'regex'];
/** /**
* The version that ES is running, in comparable string form XXX-XXX-XXX, fetched when needed * The version that ES is running, in comparable string form XXX-XXX-XXX, fetched when needed
* @type {String} * @type {String}
@ -114,7 +116,7 @@ function YamlDoc(doc, file) {
var method = self['do_' + action.name]; var method = self['do_' + action.name];
// check that it's a function // check that it's a function
expect(method).to.be.a('function'); expect(method || 'YamlDoc#' + action.name).to.be.a('function');
if (_.isPlainObject(action.args)) { if (_.isPlainObject(action.args)) {
action.name += '(' + JSON.stringify(action.args) + ')'; action.name += '(' + JSON.stringify(action.args) + ')';
@ -260,24 +262,39 @@ YamlDoc.prototype = {
* @param done * @param done
*/ */
do_skip: function (args, done) { do_skip: function (args, done) {
if (!args.version) { if (args.version) {
return done(); return rangeMatchesCurrentVersion(args.version, _.bind(function (match) {
if (match) {
if (this.description === 'setup') {
this.file.skipping = true;
// console.log('skipping this file' + (args.reason ? ' because ' + args.reason : ''));
} else {
this.skipping = true;
// console.log('skipping the rest of this doc' + (args.reason ? ' because ' + args.reason : ''));
}
} else {
this.skipping = false;
this.file.skipping = false;
}
done();
}, this));
} }
rangeMatchesCurrentVersion(args.version, _.bind(function (match) {
if (match) { if (args.features) {
var features = Array.isArray(args.features) ? args.features : [args.features];
var notImplemented = _.difference(features, implementedFeatures);
if (notImplemented.length) {
if (this.description === 'setup') { if (this.description === 'setup') {
this.file.skipping = true; this.file.skipping = true;
// console.log('skipping this file' + (args.reason ? ' because ' + args.reason : '')); console.log('skipping this file because ' + notImplemented.join(' & ') + ' are not implemented');
} else { } else {
this.skipping = true; this.skipping = true;
// console.log('skipping the rest of this doc' + (args.reason ? ' because ' + args.reason : '')); console.log('skipping the rest of this doc because ' + notImplemented.join(' & ') + ' are not implemented');
} }
} else {
this.skipping = false;
this.file.skipping = false;
} }
done(); return done();
}, this)); }
}, },
/** /**
@ -469,6 +486,18 @@ YamlDoc.prototype = {
}, this); }, this);
}, },
/**
* Test that the response field (arg key) is less than the value specified
*
* @param {Object} args - Hash of fields->values that need to be checked
* @return {undefined}
*/
do_lte: function (args) {
_.forOwn(args, function (num, path) {
expect(this.get(path) <= num).to.be.ok('path: ' + path);
}, this);
},
/** /**
* Test that the response field (arg key) is greater than the value specified * Test that the response field (arg key) is greater than the value specified
* *
@ -481,6 +510,18 @@ YamlDoc.prototype = {
}, this); }, this);
}, },
/**
* Test that the response field (arg key) is greater than the value specified
*
* @param {Object} args - Hash of fields->values that need to be checked
* @return {undefined}
*/
do_gte: function (args) {
_.forOwn(args, function (num, path) {
expect(this.get(path) >= num).to.be.ok('path: ' + path);
}, this);
},
/** /**
* Test that the response field (arg key) has a length equal to that specified. * Test that the response field (arg key) has a length equal to that specified.
* For object values, checks the length of the keys. * For object values, checks the length of the keys.