forked from NodeBB/NodeBB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.js
66 lines (56 loc) · 1.65 KB
/
database.js
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
'use strict';
const assert = require('assert');
const nconf = require('nconf');
const db = require('./mocks/databasemock');
describe('Test database', () => {
it('should work', () => {
assert.doesNotThrow(() => {
require('./mocks/databasemock');
});
});
describe('info', () => {
it('should return info about database', (done) => {
db.info(db.client, (err, info) => {
assert.ifError(err);
assert(info);
done();
});
});
it('should not error and return info if client is falsy', (done) => {
db.info(null, (err, info) => {
assert.ifError(err);
assert(info);
done();
});
});
});
describe('checkCompatibility', () => {
it('should not throw', (done) => {
db.checkCompatibility(done);
});
it('should return error with a too low version', (done) => {
const dbName = nconf.get('database');
if (dbName === 'redis') {
db.checkCompatibilityVersion('2.4.0', (err) => {
assert.equal(err.message, 'Your Redis version is not new enough to support NodeBB, please upgrade Redis to v2.8.9 or higher.');
done();
});
} else if (dbName === 'mongo') {
db.checkCompatibilityVersion('1.8.0', (err) => {
assert.equal(err.message, 'The `mongodb` package is out-of-date, please run `./nodebb setup` again.');
done();
});
} else if (dbName === 'postgres') {
db.checkCompatibilityVersion('6.3.0', (err) => {
assert.equal(err.message, 'The `pg` package is out-of-date, please run `./nodebb setup` again.');
done();
});
}
});
});
require('./database/keys');
require('./database/list');
require('./database/sets');
require('./database/hash');
require('./database/sorted');
});