Skip to content

Commit

Permalink
restore test, check for empty body
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkime committed Jun 12, 2023
1 parent 2b2bc05 commit f49f8cd
Showing 1 changed file with 42 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
*/

import expect from '@kbn/expect';
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
import { FtrProviderContext } from '../../../../ftr_provider_context';
import { configArray } from '../../constants';

const version = '2023-10-31';

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

Expand All @@ -18,30 +21,55 @@ export default function ({ getService }: FtrProviderContext) {
describe(config.name, () => {
it('deletes an index_pattern', async () => {
const title = `foo-${Date.now()}-${Math.random()}*`;
const response1 = await supertest.post(config.path).send({
[config.serviceKey]: {
title,
},
});
const response2 = await supertest.get(
`${config.path}/${response1.body[config.serviceKey].id}`
);
const response1 = await supertest
.post(config.path)
.set(ELASTIC_HTTP_VERSION_HEADER, version)
.send({
[config.serviceKey]: {
title,
},
});

const response2 = await supertest
.get(`${config.path}/${response1.body[config.serviceKey].id}`)
.set(ELASTIC_HTTP_VERSION_HEADER, version);

expect(response2.status).to.be(200);

const response3 = await supertest.delete(
`${config.path}/${response1.body[config.serviceKey].id}`
);
const response3 = await supertest
.delete(`${config.path}/${response1.body[config.serviceKey].id}`)
.set(ELASTIC_HTTP_VERSION_HEADER, version);

expect(response3.status).to.be(200);

const response4 = await supertest.get(
`${config.path}/${response1.body[config.serviceKey].id}`
);
const response4 = await supertest
.get(`${config.path}/${response1.body[config.serviceKey].id}`)
.set(ELASTIC_HTTP_VERSION_HEADER, version);

expect(response4.status).to.be(404);
});
});

it('returns nothing', async () => {
const title = `foo-${Date.now()}-${Math.random()}*`;
const response1 = await supertest

.post(config.path)
.set(ELASTIC_HTTP_VERSION_HEADER, version)
.send({
[config.serviceKey]: {
title,
},
});

await supertest.get(`${config.path}/${response1.body[config.serviceKey].id}`);
const response2 = await supertest
.delete(`${config.path}/${response1.body[config.serviceKey].id}`)
.set(ELASTIC_HTTP_VERSION_HEADER, version);

// verify empty response
expect(Object.keys(response2.body).length).to.be(0);
});
});
});
}

0 comments on commit f49f8cd

Please sign in to comment.