Skip to content

Commit

Permalink
Add unload command to certs test.
Browse files Browse the repository at this point in the history
  • Loading branch information
justinkambic committed Apr 16, 2020
1 parent bcfb42f commit 05f4606
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions x-pack/test/api_integration/apis/uptime/rest/certs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { CertType } from '../../../../../legacy/plugins/uptime/common/runtime_ty
export default function({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
const legacyEsService = getService('legacyEs');
const esArchiver = getService('esArchiver');

describe('certs api', () => {
describe('empty index', async () => {
Expand All @@ -23,6 +24,7 @@ export default function({ getService }: FtrProviderContext) {
expect(JSON.stringify(apiResponse.body)).to.eql('{"certs":[]}');
});
});

describe('when data is present', async () => {
const now = moment();
const cnva = now.add(6, 'months').toISOString();
Expand Down Expand Up @@ -59,15 +61,21 @@ export default function({ getService }: FtrProviderContext) {
d => d
);
});
after('unload test docs', () => {
esArchiver.unload('uptime/blank');
});

it('pause so I can check stuff', async () => {
const apiResponse = await supertest.get(API_URLS.CERTS);
const { body } = apiResponse;

expect(body.certs).not.to.be(undefined);
expect(Array.isArray(body.certs)).to.be(true);
expect(body.certs).to.have.length(1);

const decoded = CertType.decode(body.certs[0]);
expect(isRight(decoded)).to.be(true);

const cert = body.certs[0];
expect(Array.isArray(cert.monitors)).to.be(true);
expect(cert.monitors[0]).to.eql({ id: monitorId });
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/api_integration/apis/uptime/rest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function({ getService, loadTestFile }: FtrProviderContext) {
});

describe('with generated data', () => {
before('load heartbeat data', async () => await esArchiver.load('uptime/blank'));
beforeEach('load heartbeat data', async () => await esArchiver.loadIfNeeded('uptime/blank'));
after('unload', async () => await esArchiver.unload('uptime/blank'));

loadTestFile(require.resolve('./certs'));
Expand Down

0 comments on commit 05f4606

Please sign in to comment.