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

23 lines
615 B
JavaScript
Raw Normal View History

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