[ML] Fix for check for enabled xpack features (#24986)
This commit is contained in:
parent
df69626a30
commit
38e200f11f
2 changed files with 42 additions and 1 deletions
41
x-pack/plugins/ml/public/license/__tests__/check_license.js
Normal file
41
x-pack/plugins/ml/public/license/__tests__/check_license.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
import expect from 'expect.js';
|
||||
import {
|
||||
xpackFeatureProvider,
|
||||
} from '../check_license';
|
||||
|
||||
function Private() {
|
||||
return {
|
||||
get(str) {
|
||||
if (str === 'features.watcher.isAvailable') {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
describe('ML - check license', () => {
|
||||
|
||||
describe('xpackFeatureProvider', () => {
|
||||
it('returns true for enabled feature', () => {
|
||||
const xpackFeature = xpackFeatureProvider(Private);
|
||||
const result = xpackFeature.isAvailable('watcher');
|
||||
expect(result).to.be(true);
|
||||
});
|
||||
|
||||
it('returns false for disabled feature', () => {
|
||||
const xpackFeature = xpackFeatureProvider(Private);
|
||||
const result = xpackFeature.isAvailable('noSuchFeature');
|
||||
expect(result).to.be(false);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -119,7 +119,7 @@ export function xpackFeatureProvider(Private) {
|
|||
|
||||
return {
|
||||
isAvailable(feature) {
|
||||
xpackInfo.get(`features.${feature}.isAvailable`, false);
|
||||
return xpackInfo.get(`features.${feature}.isAvailable`, false);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue