Skip to content

Commit

Permalink
[ML] Fix for check for enabled xpack features (#24986)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic authored Nov 1, 2018
1 parent df69626 commit 38e200f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
41 changes: 41 additions & 0 deletions x-pack/plugins/ml/public/license/__tests__/check_license.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
});
2 changes: 1 addition & 1 deletion x-pack/plugins/ml/public/license/check_license.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export function xpackFeatureProvider(Private) {

return {
isAvailable(feature) {
xpackInfo.get(`features.${feature}.isAvailable`, false);
return xpackInfo.get(`features.${feature}.isAvailable`, false);
}
};
}

0 comments on commit 38e200f

Please sign in to comment.