1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/test/fixtures/fake-strategies-store.js

23 lines
723 B
JavaScript
Raw Normal View History

2016-11-05 17:02:46 +01:00
'use strict';
const NotFoundError = require('../../lib/error/notfound-error');
2016-11-13 15:41:35 +01:00
module.exports = () => {
2017-06-29 08:42:03 +02:00
const _strategies = [{ name: 'default', editable: false, parameters: {} }];
2016-11-13 15:41:35 +01:00
return {
getStrategies: () => Promise.resolve(_strategies),
getEditableStrategies: () =>
Promise.resolve(_strategies.filter(s => s.editable)),
getStrategy: name => {
2016-12-13 13:59:52 +01:00
const strategy = _strategies.find(s => s.name === name);
if (strategy) {
return Promise.resolve(strategy);
} else {
return Promise.reject(new NotFoundError('Not found!'));
}
},
addStrategy: strat => _strategies.push(strat),
2016-11-13 15:41:35 +01:00
};
2016-11-05 17:02:46 +01:00
};