Files
NodeBB/test/database.js

67 lines
1.7 KiB
JavaScript
Raw Normal View History

2015-01-03 20:07:09 -05:00
'use strict';
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');
describe('Test database', function () {
2016-10-15 10:16:58 +03:00
it('should work', function () {
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();
});
});
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);
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();
});
} 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-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');
});