2015-01-03 20:07:09 -05:00
|
|
|
'use strict';
|
2017-02-17 21:55:19 -07:00
|
|
|
|
2015-01-03 20:07:09 -05:00
|
|
|
|
2016-10-15 10:16:58 +03:00
|
|
|
var assert = require('assert');
|
2017-05-19 20:24:54 -04:00
|
|
|
var nconf = require('nconf');
|
2016-10-15 10:16:58 +03:00
|
|
|
var db = require('./mocks/databasemock');
|
2013-10-30 01:47:27 +02:00
|
|
|
|
|
|
|
|
|
2016-10-13 11:43:39 +02:00
|
|
|
describe('Test database', function () {
|
2016-10-15 10:16:58 +03:00
|
|
|
it('should work', function () {
|
2016-10-25 21:34:47 +02:00
|
|
|
assert.doesNotThrow(function () {
|
2016-10-15 10:16:58 +03:00
|
|
|
require('./mocks/databasemock');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2017-05-19 20:24:54 -04:00
|
|
|
describe('info', function () {
|
|
|
|
|
it('should return info about database', function (done) {
|
|
|
|
|
db.info(db.client, function (err, info) {
|
|
|
|
|
assert.ifError(err);
|
|
|
|
|
assert(info);
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2018-12-10 15:30:10 -05:00
|
|
|
it('should not error and return info if client is falsy', function (done) {
|
2017-05-19 20:24:54 -04:00
|
|
|
db.info(null, function (err, info) {
|
|
|
|
|
assert.ifError(err);
|
2018-12-10 15:30:10 -05:00
|
|
|
assert(info);
|
2017-05-19 20:24:54 -04:00
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('checkCompatibility', function () {
|
|
|
|
|
it('should not throw', function (done) {
|
|
|
|
|
db.checkCompatibility(done);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return error with a too low version', function (done) {
|
|
|
|
|
var dbName = nconf.get('database');
|
|
|
|
|
if (dbName === 'redis') {
|
|
|
|
|
db.checkCompatibilityVersion('2.4.0', function (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', function (err) {
|
|
|
|
|
assert.equal(err.message, 'The `mongodb` package is out-of-date, please run `./nodebb setup` again.');
|
|
|
|
|
done();
|
|
|
|
|
});
|
2018-08-08 14:13:48 -05:00
|
|
|
} else if (dbName === 'postgres') {
|
|
|
|
|
db.checkCompatibilityVersion('6.3.0', function (err) {
|
|
|
|
|
assert.equal(err.message, 'The `pg` package is out-of-date, please run `./nodebb setup` again.');
|
|
|
|
|
done();
|
|
|
|
|
});
|
2017-05-19 20:24:54 -04:00
|
|
|
}
|
2013-10-30 01:47:27 +02:00
|
|
|
});
|
|
|
|
|
});
|
2013-12-06 13:46:12 -05:00
|
|
|
|
2017-05-19 20:24:54 -04:00
|
|
|
|
2014-12-25 02:43:11 -05:00
|
|
|
require('./database/keys');
|
2014-12-29 16:20:35 -05:00
|
|
|
require('./database/list');
|
2014-12-29 17:55:30 -05:00
|
|
|
require('./database/sets');
|
2014-12-30 18:07:06 -05:00
|
|
|
require('./database/hash');
|
2014-12-31 14:27:16 -05:00
|
|
|
require('./database/sorted');
|
2013-10-30 01:47:27 +02:00
|
|
|
});
|