2019-11-01 18:30:06 +00:00
|
|
|
const client = require('../lib/dist');
|
2017-10-18 21:39:25 +00:00
|
|
|
const userCredentials = new client.UserCredentials('admin', 'changeit');
|
|
|
|
|
|
|
|
const log = new client.NoopLogger();
|
2023-01-30 20:08:46 +00:00
|
|
|
const httpEndpoint = `https://${process.env.EVENTSTORE_HOST || "localhost"}:2113`;
|
2017-10-18 21:39:25 +00:00
|
|
|
const operationTimeout = 5000;
|
|
|
|
|
|
|
|
const simpleProjection = "\
|
|
|
|
fromStream('$stats-127.0.0.1:2113')\
|
|
|
|
.when({\
|
|
|
|
$init: function(){\
|
|
|
|
return {\
|
|
|
|
count: 0\
|
|
|
|
}\
|
|
|
|
},\
|
|
|
|
$any: function(s,e){\
|
|
|
|
s.count += 1;\
|
|
|
|
}\
|
|
|
|
})\
|
|
|
|
";
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
setUp: function(cb) {
|
2023-01-30 20:08:46 +00:00
|
|
|
this.projectionsManager = new client.ProjectionsManager(log, httpEndpoint, operationTimeout, false);
|
2017-10-18 21:39:25 +00:00
|
|
|
cb();
|
|
|
|
},
|
|
|
|
'Create One Time Projection Happy Path': function(test) {
|
|
|
|
test.expect(1);
|
|
|
|
|
|
|
|
this.projectionsManager.createOneTime(simpleProjection, userCredentials)
|
|
|
|
.then(function (result) {
|
|
|
|
test.equal(result, undefined);
|
|
|
|
test.done();
|
|
|
|
})
|
|
|
|
.catch(test.done);
|
|
|
|
},
|
|
|
|
'List All Happy Path': function(test) {
|
|
|
|
test.expect(1);
|
|
|
|
this.projectionsManager.listAll(userCredentials)
|
|
|
|
.then(function (projections) {
|
|
|
|
test.ok(projections.length > 0, "no projections");
|
|
|
|
test.done();
|
|
|
|
})
|
|
|
|
.catch(test.done);
|
|
|
|
}
|
|
|
|
//TODO: other tests
|
2019-11-01 18:30:06 +00:00
|
|
|
};
|