From edaf51529dbb1c9714d35607c0ee0d3c97b2d266 Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Tue, 7 Apr 2020 10:16:19 -0400 Subject: [PATCH] cleanup --- .../server/routes/api/update.ts | 2 +- .../ingest_pipelines/lib/elasticsearch.ts | 22 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts b/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts index 794845b33860df..fa5ee440285f11 100644 --- a/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts +++ b/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts @@ -40,7 +40,7 @@ export const registerUpdateRoute = ({ const { description, processors, version } = pipeline; try { - // Verify pipeline exists + // Verify pipeline exists; ES will throw 404 if it doesn't await callAsCurrentUser('ingest.getPipeline', { id: name }); const response = await callAsCurrentUser('ingest.putPipeline', { diff --git a/x-pack/test/api_integration/apis/management/ingest_pipelines/lib/elasticsearch.ts b/x-pack/test/api_integration/apis/management/ingest_pipelines/lib/elasticsearch.ts index 3c87faa2ea9f04..2f42596a66b546 100644 --- a/x-pack/test/api_integration/apis/management/ingest_pipelines/lib/elasticsearch.ts +++ b/x-pack/test/api_integration/apis/management/ingest_pipelines/lib/elasticsearch.ts @@ -5,34 +5,32 @@ */ import { FtrProviderContext } from '../../../../ftr_provider_context'; +interface Processor { + [key: string]: { + [key: string]: unknown; + }; +} + interface Pipeline { id: string; body: { description: string; - processors: any[]; + processors: Processor[]; version?: number; }; } /** - * Helpers to create and delete indices on the Elasticsearch instance + * Helpers to create and delete pipelines on the Elasticsearch instance * during our tests. * @param {ElasticsearchClient} es The Elasticsearch client instance */ export const registerEsHelpers = (getService: FtrProviderContext['getService']) => { const es = getService('legacyEs'); - let pipelinesCreated: Pipeline[] = []; + const createPipeline = (pipeline: Pipeline) => es.ingest.putPipeline(pipeline); - const createPipeline = (pipeline: Pipeline) => { - pipelinesCreated.push(pipeline); - return es.ingest.putPipeline(pipeline).then(() => pipeline); - }; - - const deletePipeline = (pipelineId: string) => { - pipelinesCreated = pipelinesCreated.filter(({ id }) => id !== pipelineId); - return es.ingest.deletePipeline({ id: pipelineId }); - }; + const deletePipeline = (pipelineId: string) => es.ingest.deletePipeline({ id: pipelineId }); return { createPipeline,