Skip to content

Commit

Permalink
[7.9] Fix condition for filtering to installed packages (elastic#79205)…
Browse files Browse the repository at this point in the history
… (elastic#79225)

* Fix condition for filtering to installed packages (elastic#79205)

# Conflicts:
#	x-pack/plugins/ingest_manager/server/services/epm/packages/get.ts

* Patch test fix from b08f4c9
  • Loading branch information
jen-huang authored Oct 2, 2020
1 parent 5af8bfc commit f1c78b7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function getLimitedPackages(options: {
const { savedObjectsClient } = options;
const allPackages = await getPackages({ savedObjectsClient, experimental: true });
const installedPackages = allPackages.filter(
(pkg) => (pkg.status = InstallationStatus.installed)
(pkg) => pkg.status === InstallationStatus.installed
);
const installedPackagesInfo = await Promise.all(
installedPackages.map((pkgInstall) => {
Expand Down
28 changes: 12 additions & 16 deletions x-pack/test/ingest_manager_api_integration/apis/epm/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../api_integration/ftr_provider_context';
import { warnAndSkipTest } from '../../helpers';
import { skipIfNoDockerRegistry } from '../../helpers';
import { setupIngest } from '../fleet/agents/services';

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

const server = dockerServers.get('registry');
// use function () {} and not () => {} here
// because `this` has to point to the Mocha context
// see https://mochajs.org/#arrow-functions

describe('EPM - list', async function () {
it('lists all packages from the registry', async function () {
if (server.enabled) {
skipIfNoDockerRegistry(providerContext);
setupIngest(providerContext);

describe('list api tests', async () => {
it('lists all packages from the registry', async function () {
const fetchPackageList = async () => {
const response = await supertest
.get('/api/ingest_manager/epm/packages')
Expand All @@ -30,13 +32,9 @@ export default function ({ getService }: FtrProviderContext) {
};
const listResponse = await fetchPackageList();
expect(listResponse.response.length).to.be(5);
} else {
warnAndSkipTest(this, log);
}
});
});

it('lists all limited packages from the registry', async function () {
if (server.enabled) {
it('lists all limited packages from the registry', async function () {
const fetchLimitedPackageList = async () => {
const response = await supertest
.get('/api/ingest_manager/epm/packages/limited')
Expand All @@ -46,9 +44,7 @@ export default function ({ getService }: FtrProviderContext) {
};
const listResponse = await fetchLimitedPackageList();
expect(listResponse.response).to.eql(['endpoint']);
} else {
warnAndSkipTest(this, log);
}
});
});
});
}

0 comments on commit f1c78b7

Please sign in to comment.