fix agg name in test, throw exception when aggrigations are defined but the key can't be found

This commit is contained in:
Joe Fleming 2014-09-02 15:20:44 -07:00
parent 5c3ca1cc08
commit a30249c08c
2 changed files with 4 additions and 2 deletions

View file

@ -304,6 +304,8 @@ define(function (require) {
return key.substr(0, 4) === 'agg_';
});
if (!aggKey) throw new Error('aggKey not found in response: ' + Object.keys(resp.aggregations));
// start merging aggregations
if (!requestStats.aggregations) {
requestStats.aggregations = {};

View file

@ -171,7 +171,7 @@ define(function (require) {
max_score: score
},
aggregations: {
'_agg_test': {
'agg_test': {
buckets: [{
doc_count: hits.length,
key: aggKey
@ -213,7 +213,7 @@ define(function (require) {
function eachHandler(resp, req) {
// check results from mergeRequestStats
expect(segmentedFetch.requestStats).to.have.property('aggregations');
expect(segmentedFetch.requestStats.aggregations['_agg_test'].buckets.length).to.be(aggregationKeys.length);
expect(segmentedFetch.requestStats.aggregations['agg_test'].buckets.length).to.be(aggregationKeys.length);
expect(segmentedFetch.requestStats.took).to.be(totalTime);
expect(segmentedFetch.requestStats.hits.hits.length).to.be(totalHits);
expect(segmentedFetch.requestStats.hits.total).to.be(maxHits);