mirror of
https://github.com/Hopiu/webapi-eca.git
synced 2026-03-17 06:20:23 +00:00
87 lines
2.1 KiB
JavaScript
87 lines
2.1 KiB
JavaScript
// Generated by CoffeeScript 1.6.3
|
|
(function() {
|
|
var _this = this;
|
|
|
|
exports.setUp = function(cb) {
|
|
_this.path = require('path');
|
|
_this.db = require(path.join('..', 'js-coffee', 'persistence'));
|
|
console.log('setup');
|
|
console.log(_this.db);
|
|
_this.db({
|
|
logType: 2
|
|
});
|
|
return cb();
|
|
};
|
|
|
|
exports.tearDown = function(cb) {
|
|
_this.db.shutDown();
|
|
return cb();
|
|
};
|
|
|
|
/*
|
|
# Test AVAILABILITY
|
|
*/
|
|
|
|
|
|
exports.Availability = {
|
|
setUp: function(cb) {
|
|
_this.path = require('path');
|
|
_this.db = require(path.join('..', 'js-coffee', 'persistence'));
|
|
console.log('setup');
|
|
console.log(_this.db);
|
|
_this.db({
|
|
logType: 2
|
|
});
|
|
return cb();
|
|
},
|
|
testRequire: function(test) {
|
|
test.expect(1);
|
|
console.log('setup');
|
|
test.ok(_this.db, 'DB interface loaded');
|
|
return test.done();
|
|
},
|
|
testConnect: function(test) {
|
|
test.expect(1);
|
|
return _this.db.isConnected(function(err) {
|
|
test.ifError(err, 'Connection failed!');
|
|
return test.done();
|
|
});
|
|
},
|
|
testNoConfig: function(test) {
|
|
test.expect(1);
|
|
_this.db({
|
|
configPath: 'nonexistingconf.file'
|
|
});
|
|
return _this.db.isConnected(function(err) {
|
|
test.ok(err, 'Still connected!?');
|
|
return test.done();
|
|
});
|
|
},
|
|
testWrongConfig: function(test) {
|
|
test.expect(1);
|
|
_this.db({
|
|
configPath: _this.path.join('testing', 'jsonWrongConfig.json')
|
|
});
|
|
return _this.db.isConnected(function(err) {
|
|
test.ok(err, 'Still connected!?');
|
|
return test.done();
|
|
});
|
|
},
|
|
testPurgeQueue: function(test) {
|
|
var evt;
|
|
test.expect(2);
|
|
evt = {
|
|
eventid: '1',
|
|
event: 'mail'
|
|
};
|
|
_this.db.pushEvent(evt);
|
|
_this.db.purgeEventQueue();
|
|
return _this.db.popEvent(function(err, obj) {
|
|
test.ifError(err, 'Error during pop after purging!');
|
|
test.strictEqual(obj, null, 'There was an event in the queue!?');
|
|
return test.done();
|
|
});
|
|
}
|
|
};
|
|
|
|
}).call(this);
|