updated tests to be compatible with the limited api version available in the browser_client, and updated grunt-saucelabs
This commit is contained in:
64
package.json
64
package.json
@ -33,41 +33,41 @@
|
||||
"default_api_branch": "1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^1.21",
|
||||
"async": "~0.8.0",
|
||||
"moment": "~2.4.0",
|
||||
"js-yaml": "~2.1.3",
|
||||
"optimist": "~0.6.0",
|
||||
"browserify": "~2.35.1",
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-contrib-jshint": "~0.7.1",
|
||||
"grunt-browserify": "~1.2.11",
|
||||
"grunt-contrib-clean": "~0.5.0",
|
||||
"grunt-contrib-uglify": "~0.2.7",
|
||||
"grunt-contrib-concat": "~0.3.0",
|
||||
"xmlbuilder": "~0.4.3",
|
||||
"grunt-contrib-watch": "~0.5.3",
|
||||
"mocha-lcov-reporter": "0.0.1",
|
||||
"blanket": "~1.1.5",
|
||||
"sinon": "~1.7.3",
|
||||
"nock": "~0.28.1",
|
||||
"open": "0.0.4",
|
||||
"load-grunt-tasks": "~0.2.0",
|
||||
"load-grunt-config": "~0.7.0",
|
||||
"grunt-s3": "~0.2.0-alpha.3",
|
||||
"grunt-run": "~0.2.2",
|
||||
"grunt-contrib-compress": "~0.5.3",
|
||||
"grunt-contrib-copy": "~0.4.1",
|
||||
"grunt-prompt": "~0.1.2",
|
||||
"grunt-mocha-cov": "~0.2.0",
|
||||
"grunt-open": "~0.2.2",
|
||||
"glob": "~3.2.7",
|
||||
"expect.js": "~0.2.0",
|
||||
"aliasify": "~1.2.4",
|
||||
"async": "~0.8.0",
|
||||
"blanket": "~1.1.5",
|
||||
"browserify": "~2.35.1",
|
||||
"event-stream": "~3.1.0",
|
||||
"expect.js": "~0.2.0",
|
||||
"express": "~3.4.7",
|
||||
"find-root": "~0.1.1",
|
||||
"event-stream": "~3.1.0",
|
||||
"grunt-saucelabs": "~5.1.0"
|
||||
"glob": "~3.2.7",
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-browserify": "~1.2.11",
|
||||
"grunt-contrib-clean": "~0.5.0",
|
||||
"grunt-contrib-compress": "~0.5.3",
|
||||
"grunt-contrib-concat": "~0.3.0",
|
||||
"grunt-contrib-copy": "~0.4.1",
|
||||
"grunt-contrib-jshint": "~0.7.1",
|
||||
"grunt-contrib-uglify": "~0.2.7",
|
||||
"grunt-contrib-watch": "~0.5.3",
|
||||
"grunt-mocha-cov": "~0.2.0",
|
||||
"grunt-open": "~0.2.2",
|
||||
"grunt-prompt": "~0.1.2",
|
||||
"grunt-run": "~0.2.2",
|
||||
"grunt-s3": "~0.2.0-alpha.3",
|
||||
"grunt-saucelabs": "~8.2.0",
|
||||
"js-yaml": "~2.1.3",
|
||||
"load-grunt-config": "~0.7.0",
|
||||
"load-grunt-tasks": "~0.2.0",
|
||||
"mocha": "^1.21",
|
||||
"mocha-lcov-reporter": "0.0.1",
|
||||
"moment": "~2.4.0",
|
||||
"nock": "~0.28.1",
|
||||
"open": "0.0.4",
|
||||
"optimist": "~0.6.0",
|
||||
"sinon": "~1.7.3",
|
||||
"xmlbuilder": "~0.4.3"
|
||||
},
|
||||
"license": "Apache 2.0",
|
||||
"dependencies": {
|
||||
|
||||
@ -17,9 +17,34 @@
|
||||
</script>
|
||||
<script src="unit_tests.js"></script>
|
||||
<script>
|
||||
mochaRunner = mocha.run().on('end', function(){
|
||||
window.mochaResults = this.stats;
|
||||
});
|
||||
(function (root) {
|
||||
var failedTests = [];
|
||||
|
||||
var flattenTitles = function (test) {
|
||||
var titles = [];
|
||||
while (test && test.parent && test.parent.title) {
|
||||
titles.unshift(test.parent.title);
|
||||
test = test.parent
|
||||
}
|
||||
return titles;
|
||||
};
|
||||
|
||||
var runner = root.mochaRunner = mocha.run()
|
||||
.on('end', function(){
|
||||
window.mochaResults = runner.stats;
|
||||
window.mochaResults.reports = failedTests;
|
||||
})
|
||||
.on('fail', function logFailure(test, err){
|
||||
failedTests.push({
|
||||
name: test.title,
|
||||
result: false,
|
||||
message: err.message,
|
||||
stack: err.stack,
|
||||
titles: flattenTitles(test)
|
||||
});
|
||||
});
|
||||
|
||||
}(window));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -23,6 +23,13 @@ var ES_VERSION = null;
|
||||
// core expression for finding a version
|
||||
var versionExp = '([\\d\\.]*\\d)(?:\\.\\w+)?';
|
||||
|
||||
// match all whitespace within a "regexp" match arg
|
||||
var reWhitespace_RE = /\s+/g;
|
||||
|
||||
// match all comments within a "regexp" match arg
|
||||
var reComments_RE = /([\S\s]?)#[^\n]*\n/g;
|
||||
|
||||
|
||||
/**
|
||||
* Regular Expression to extract a version number from a string
|
||||
* @type {RegExp}
|
||||
@ -468,36 +475,68 @@ YamlDoc.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Test that the response field (arg key) matches the value specified
|
||||
* Test that the response field (arg key) matches the value specified.
|
||||
*
|
||||
* @param {Object} args - Args can be specified in a number of formats:
|
||||
*
|
||||
* object{ <path>: <string|number|obj> }
|
||||
* - used to match simple values against properties of the last response body
|
||||
* - keys are "paths" to values in the previous response
|
||||
* - values are what they should match
|
||||
* example:
|
||||
* resp:
|
||||
* {
|
||||
* hits: {
|
||||
* total: 100,
|
||||
* hits: [ ... ]
|
||||
* }
|
||||
* }
|
||||
* args:
|
||||
* {
|
||||
* "hits.total": 100,
|
||||
* }
|
||||
*
|
||||
*
|
||||
* object{ <path>: <RegExp> }
|
||||
* - regexp is expressed as a string that starts and ends with a /
|
||||
* - we have to make several replacements on the string before converting
|
||||
* it into a regexp because javascript doesn't support the "verbose" mode
|
||||
* they are written for.
|
||||
*
|
||||
* @param {Object} args - Hash of fields->values that need to be checked
|
||||
* @return {undefined}
|
||||
*/
|
||||
do_match: function (args) {
|
||||
var self = this;
|
||||
|
||||
// recursively replace all $var within args
|
||||
_.forOwn(args, function recurse(val, key, lvl) {
|
||||
if (_.isObject(val)) {
|
||||
return _.each(val, recurse);
|
||||
}
|
||||
|
||||
if (_.isString(val) && val[0] === '$') {
|
||||
lvl[key] = self.get(val);
|
||||
}
|
||||
});
|
||||
|
||||
_.forOwn(args, function (match, path) {
|
||||
var matchPastRef = _.isString(match) && match[0] === '$';
|
||||
if (matchPastRef) {
|
||||
// we are trying to match against a value stored in the stack
|
||||
match = this.get(match);
|
||||
}
|
||||
var origMatch = match;
|
||||
|
||||
if (_.isObject(match)) {
|
||||
var self = this;
|
||||
// we need to check all sub values for $var
|
||||
_.each(match, function recurse(val, key, lvl) {
|
||||
if (_.isObject(val)) {
|
||||
return _.each(val, recurse);
|
||||
}
|
||||
|
||||
if (_.isString(val) && val[0] === '$') {
|
||||
lvl[key] = self.get(val);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var notRE = match;
|
||||
var maybeRE = _.isString(match) && match.replace(/#[^\n]*\n/g, '\n').replace(/\s+/g, '');
|
||||
var maybeRE = false;
|
||||
var usedRE = false;
|
||||
|
||||
if (_.isString(match)) {
|
||||
maybeRE = match
|
||||
.replace(reComments_RE, function (match, prevChar) {
|
||||
if (prevChar === '\\') {
|
||||
return match;
|
||||
} else {
|
||||
return prevChar + '\n';
|
||||
}
|
||||
})
|
||||
.replace(reWhitespace_RE, '');
|
||||
}
|
||||
|
||||
if (maybeRE && maybeRE[0] === '/' && maybeRE[maybeRE.length - 1] === '/') {
|
||||
usedRE = true;
|
||||
// replace anymore than one space with a single space
|
||||
@ -521,8 +560,8 @@ YamlDoc.prototype = {
|
||||
inspect(path),
|
||||
'and value',
|
||||
inspect(val),
|
||||
'and original RE',
|
||||
'|' + notRE,
|
||||
'and original matcher',
|
||||
'|' + origMatch,
|
||||
''
|
||||
];
|
||||
throw new Error(msg.slice(0, usedRE ? void 0 : -3).join('\n'));
|
||||
|
||||
@ -27,13 +27,13 @@ describe('Client instances creation', function () {
|
||||
expect(client.nodes.stats).to.be(apis[def].nodes.prototype.stats);
|
||||
});
|
||||
|
||||
it('inherits the 1.0 API when specified', function () {
|
||||
it('inherits the 1.2 API when specified', function () {
|
||||
client.close();
|
||||
client = es.Client({
|
||||
apiVersion: '1.0'
|
||||
apiVersion: '1.2'
|
||||
});
|
||||
expect(client.bulk).to.be(apis['1.0'].bulk);
|
||||
expect(client.cluster.nodeStats).to.be(apis['1.0'].cluster.prototype.nodeStats);
|
||||
expect(client.bulk).to.be(apis['1.2'].bulk);
|
||||
expect(client.cluster.nodeStats).to.be(apis['1.2'].cluster.prototype.nodeStats);
|
||||
});
|
||||
|
||||
it('closing the client causes it\'s transport to be closed', function () {
|
||||
|
||||
Reference in New Issue
Block a user