[ML] Fix for check for enabled xpack features (#24986)

This commit is contained in:
James Gowdy 2018-11-01 16:46:57 +00:00 committed by GitHub
parent df69626a30
commit 38e200f11f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 1 deletions

View 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);
});
});
});

View file

@ -119,7 +119,7 @@ export function xpackFeatureProvider(Private) {
return {
isAvailable(feature) {
xpackInfo.get(`features.${feature}.isAvailable`, false);
return xpackInfo.get(`features.${feature}.isAvailable`, false);
}
};
}