1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/test/eventDbMock.js

68 lines
1.2 KiB
JavaScript
Raw Normal View History

2014-10-24 16:15:59 +02:00
var Promise = require("bluebird");
var events = [
{
"id": 1,
"created_at": 1414159948677,
"type": "feature-create",
"created_by": "me",
"data": {
2014-10-31 16:35:35 +01:00
2014-10-24 16:15:59 +02:00
}
},
{
"id": 2,
"created_at": 1414159948677,
"type": "feature-create",
"created_by": "me",
"data": {
"foo": "bar"
}
},
{
"id": 3,
"created_at": 1414159948677,
"type": "feature-create",
"created_by": "me",
"data": {
"foo": "rab"
}
}
];
function getEvent(name) {
var eventFound;
events.forEach(function (event) {
if (event.name === name) {
eventFound = event;
}
});
return eventFound;
}
2014-10-23 16:02:12 +02:00
function storeEvent() {
return new Promise(function (resolve) {
resolve();
});
}
module.exports = {
2014-10-24 16:15:59 +02:00
store: storeEvent,
getEvents: function() {
return new Promise(function (resolve) {
resolve(events);
});
},
getEvent: function(name) {
var event = getEvent(name);
if(event) {
return Promise.resolve(event);
} else {
return Promise.reject("Event not found");
}
}
};