From d0c263441c492e14a13d4196f4803fe1e7e36011 Mon Sep 17 00:00:00 2001 From: Ryland Herrick Date: Mon, 7 Dec 2020 13:43:09 -0600 Subject: [PATCH] Add unit test for the naming of our destination migration index --- .../create_signals_migration_index.test.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 x-pack/plugins/security_solution/server/lib/detection_engine/migrations/create_signals_migration_index.test.ts diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/create_signals_migration_index.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/create_signals_migration_index.test.ts new file mode 100644 index 0000000000000..b638e89436601 --- /dev/null +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/migrations/create_signals_migration_index.test.ts @@ -0,0 +1,25 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { ElasticsearchClient } from 'src/core/server'; +import { elasticsearchServiceMock } from 'src/core/server/mocks'; +import { createSignalsMigrationIndex } from './create_signals_migration_index'; + +describe('getMigrationStatus', () => { + let esClient: ElasticsearchClient; + + beforeEach(() => { + esClient = elasticsearchServiceMock.createElasticsearchClient(); + }); + + it('creates an index suffixed with the template version', async () => { + await createSignalsMigrationIndex({ esClient, index: 'my-signals-index', version: 4 }); + + expect(esClient.indices.create).toHaveBeenCalledWith( + expect.objectContaining({ index: 'my-signals-index-r000004' }) + ); + }); +});