This repository has been archived by the owner on Jan 10, 2022. It is now read-only.
/
lib.core.storage.js-disabled
93 lines (71 loc) · 2.78 KB
/
lib.core.storage.js-disabled
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* 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() {
})
});
});