Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkime committed Mar 16, 2021
1 parent 6fcbcc7 commit bd96814
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/plugins/data/common/search/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { IKibanaSearchResponse } from './types';
* @returns true if response had an error while executing in ES
*/
export const isErrorResponse = (response?: IKibanaSearchResponse) => {
return !response || (!response.isRunning && response.isPartial);
return !response || (!response.isRunning && !!response.isPartial);
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export const successfulResolveResponse = {
};

const successfulSearchResponse = {
isPartial: false,
isRunning: false,
rawResponse: {
aggregations: {
indices: {
Expand All @@ -44,6 +46,8 @@ const successfulSearchResponse = {
};

const partialSearchResponse = {
isPartial: true,
isRunning: true,
rawResponse: {
hits: {
total: 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ export const getIndicesViaSearch = async ({
},
},
})
.pipe(filter((resp) => isCompleteResponse(resp) || !!isErrorResponse(resp)))
.pipe(map(searchResponseToArray(getIndexTags, showAllIndices)))
.pipe(
filter((resp) => isCompleteResponse(resp) || isErrorResponse(resp)),
map(searchResponseToArray(getIndexTags, showAllIndices))
)
.toPromise()
.catch(() => []);

Expand Down

0 comments on commit bd96814

Please sign in to comment.