Skip to content

Commit

Permalink
uses product response header in createApiResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
TinaHeiligers committed Aug 17, 2021
1 parent 0cb74e0 commit 810fbdc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/server/elasticsearch/client/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { TransportRequestPromise } from '@elastic/elasticsearch/lib/Transport';
import type { DeeplyMockedKeys } from '@kbn/utility-types/jest';
import { ElasticsearchClient } from './types';
import { ICustomClusterClient } from './cluster_client';
import { PRODUCT_RESPONSE_HEADER } from '../supported_server_response_check';

const createInternalClientMock = (
res?: MockedTransportRequestPromise<unknown>
Expand Down Expand Up @@ -142,7 +143,7 @@ export type MockedTransportRequestPromise<T> = TransportRequestPromise<T> & {
const createSuccessTransportRequestPromise = <T>(
body: T,
{ statusCode = 200 }: { statusCode?: number } = {},
headers: Record<string, string | string[]> = { 'x-elastic-product': 'Elasticsearch' }
headers: Record<string, string | string[]> = { [PRODUCT_RESPONSE_HEADER]: 'Elasticsearch' }
): MockedTransportRequestPromise<ApiResponse<T>> => {
const response = createApiResponse({ body, statusCode, headers });
const promise = Promise.resolve(response);
Expand All @@ -163,7 +164,7 @@ function createApiResponse<TResponse = Record<string, any>>(
return {
body: {} as any,
statusCode: 200,
headers: { 'x-elastic-product': 'Elasticsearch' },
headers: { [PRODUCT_RESPONSE_HEADER]: 'Elasticsearch' },
warnings: [],
meta: {} as any,
...opts,
Expand Down
1 change: 1 addition & 0 deletions src/core/server/elasticsearch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ export { getRequestDebugMeta, getErrorMessage } from './client';
export {
isSupportedEsServer,
isNotFoundFromUnsupportedServer,
PRODUCT_RESPONSE_HEADER,
} from './supported_server_response_check';

0 comments on commit 810fbdc

Please sign in to comment.