Skip to content

Commit

Permalink
add unit test arguments passed to es client
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Apr 6, 2021
1 parent 6abb04f commit 76c72c5
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/core/server/saved_objects/migrationsv2/actions/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,29 @@ describe('actions', () => {

expect(catchRetryableEsClientErrors).toHaveBeenCalledWith(retryableError);
});

it('configures request according to given parameters', async () => {
const esClient = elasticsearchClientMock.createInternalClient();
const query = {};
const targetIndex = 'new_index';
const batchSize = 1000;
const task = Actions.searchForOutdatedDocuments(esClient, {
batchSize,
targetIndex,
outdatedDocumentsQuery: query,
});

await task();

expect(client.search).toHaveBeenCalledTimes(1);
expect(client.search).toHaveBeenCalledWith(
expect.objectContaining({
index: targetIndex,
size: batchSize,
body: expect.objectContaining({ query }),
})
);
});
});

describe('bulkOverwriteTransformedDocuments', () => {
Expand Down

0 comments on commit 76c72c5

Please sign in to comment.