Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sabarasaba committed Nov 29, 2021
1 parent f380922 commit 80d7c01
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 84 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export function registerGetIndexPatternsRoute({
await finder.close();

return response.ok({ body: responses });
} catch (e) {
return handleEsError({ error: e, response });
} catch (error) {
return handleEsError({ error, response });
}
})
);
Expand Down
1 change: 1 addition & 0 deletions x-pack/test/api_integration/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ export default function ({ loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./painless_lab'));
loadTestFile(require.resolve('./file_upload'));
loadTestFile(require.resolve('./ml'));
loadTestFile(require.resolve('./watcher'));
});
}
14 changes: 14 additions & 0 deletions x-pack/test/api_integration/apis/watcher/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ loadTestFile }: FtrProviderContext) {
describe('Watcher', () => {
loadTestFile(require.resolve('./watcher'));
});
}
26 changes: 26 additions & 0 deletions x-pack/test/api_integration/apis/watcher/watcher.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import expect from '@kbn/expect';

export default function ({ getService }) {
const supertest = getService('supertest');

describe('watcher', () => {
describe('POST /api/watcher/indices/index_patterns', () => {
it('returns list of index patterns', async () => {
const response = await supertest
.get('/api/watcher/indices/index_patterns')
.set('kbn-xsrf', 'kibana')
.expect(200);

const expectedResponse = ['metrics-*', 'logs-*'];
expect(response.body).to.eql(expectedResponse);
});
});
});
}

0 comments on commit 80d7c01

Please sign in to comment.