Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

94 lines (71 sloc) 2.849 kB
/**
* Mocha test case for core configuration library
*/
var should = require('should'),
fs = require('fs'),
rootpath = process.cwd() + '/',
path = require('path'),
helper = require('./helpers/calipsoHelper');
helper.finalize(function (err, calipsoHelper) {
var calipso = calipsoHelper.calipso,
dbUri,
Storage = require('./helpers/require')('core/Storage');
describe('Storage', function(){
before(function(done) {
// These have been disabled due to the linked dependency on calipso itself.
done();
});
describe('Core', function(){
it('I can connect to local mongodb in install mode', function(done){
Storage.mongoConnect('mongodb://localhost/mocha', true, function(err, connected) {
should.not.exist(err);
connected.should.equal(false);
done();
});
});
it('Connecting to an invalid server in install mode results in an error', function(done){
Storage.mongoConnect('mongodb://invalid/mocha', true, function(err, connected) {
err.should.exist; // Dont check content as this is from Mongoose and may change
connected.should.equal(false);
done();
});
});
it('If not installed, it doesnt actually connect using just mongoConnect but doesnt raise an error', function(done){
Storage.mongoConnect(function(err, connected) {
should.not.exist(err);
connected.should.equal(false);
done();
});
});
it('If installed, it does actually connect using just mongoConnect', function(done){
calipso.config.set('installed',true);
Storage.mongoConnect(function(err, connected) {
should.not.exist(err);
connected.should.equal(true);
done();
});
});
it('If it cant find the session middleware to replace, it fails', function(done){
calipso.config.set('installed',true);
calipso.app.stack = [];
Storage.mongoConnect(function(err, connected) {
should.exist(err);
err.message.should.equal('Unable to load the MongoDB backed session, please check your session and db configuration');
connected.should.equal(false);
done();
});
});
it('If the installed and the server doesnt exist, it fails', function(done){
calipso.config.set('installed',true);
calipso.config.set('database:uri','mongodb://invalid/mocha');
Storage.mongoConnect(function(err, connected) {
should.exist(err);
connected.should.equal(false);
done();
});
});
});
after(function() {
})
});
});
Jump to Line
Something went wrong with that request. Please try again.