Manually revert PR #5571: Mock responses for -*

These changes are no longer necessary since we're not using the -*
search hack to simulate empty results any longer.
This commit is contained in:
Court Ewing 2015-12-23 10:42:12 -05:00
parent 13ee0a95c7
commit e361904a07
3 changed files with 1 additions and 80 deletions

View file

@ -93,12 +93,7 @@ define(function (require) {
ignore_unavailable: true,
preference: sessionId,
body: body
}))
.catch(function (err) {
return strategy.handleResponseError
? strategy.handleResponseError(executable, err)
: Promise.reject(err);
});
}));
})
.then(function (clientResp) {
return strategy.getResponses(clientResp);

View file

@ -31,57 +31,6 @@ describe('ui/courier/fetch/strategy/search', () => {
});
});
describe('#handleResponseError()', () => {
let error;
beforeEach(() => {
error = { status: 404, body: { error: { index: '[-*]' } } };
});
it('recovers 404 for index -* with empty response', () => {
let resp;
search.handleResponseError(reqsFetchParams, error).then(val => resp = val);
$rootScope.$apply();
expect(resp.responses).not.to.be(undefined);
});
it('mocks all of the bundled searches', () => {
let resp;
reqsFetchParams.push({});
search.handleResponseError(reqsFetchParams, error).then(val => resp = val);
$rootScope.$apply();
expect(Array.isArray(resp.responses)).to.be(true);
expect(resp.responses.length).to.be(2);
resp.responses.forEach(res => {
expect(res.hits.total).to.be(0);
expect(res.hits.hits.length).to.be(0);
});
});
context('when not a 404', () => {
it('rejects with the original response', () => {
error.status = 403;
let err;
search.handleResponseError(reqsFetchParams, error).catch(val => err = val);
$rootScope.$apply();
expect(err).to.be(error);
});
});
context('when not for -* index', () => {
it('rejects with the original response', () => {
error.body.error.index = '[foo-*]';
let err;
search.handleResponseError(reqsFetchParams, error).catch(val => err = val);
$rootScope.$apply();
expect(err).to.be(error);
});
});
});
describe('#reqsFetchParamsToBody()', () => {
it('filters out any body properties that begin with $', () => {
let value;

View file

@ -4,32 +4,9 @@ define(function (require) {
var angular = require('angular');
var toJson = require('ui/utils/aggressive_parse').toJson;
function emptyResponse() {
return { hits: { total: 0, hits: [] } };
};
return {
clientMethod: 'msearch',
/**
* Recover from a 404 when searching against no indexes
*
* If we get a 404 while intentionally searching for no indexes, we can
* simply mock an empty result since that is ultimately what kibana cares
* about.
*
* @param {object} response - the client response from elasticsearch
* @return {Promise} - fulfilled by mock or rejected with original error
*/
handleResponseError: function (requests, response) {
var is404 = _.get(response, 'status') === 404;
var isEmptyIndexList = _.get(response, 'body.error.index') === '[-*]';
return is404 && isEmptyIndexList
? Promise.resolve({ responses: requests.map(emptyResponse) })
: Promise.reject(response);
},
/**
* Flatten a series of requests into as ES request body
*