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
const assert = require('assert');
2021-02-04 00:06:15 -07:00
const nconf = require('nconf');
const db = require('./mocks/databasemock');
2021-02-04 00:01:39 -07:00
describe('Test database', () => {
it('should work', () => {
assert.doesNotThrow(() => {
2016-10-15 10:16:58 +03:00
require('./mocks/databasemock');
});
});
2021-02-04 00:01:39 -07:00
describe('info', () => {
it('should return info about database', (done) => {
db.info(db.client, (err, info) => {
2017-05-19 20:24:54 -04:00
assert.ifError(err);
assert(info);
done();
});
});
2021-02-04 00:01:39 -07:00
it('should not error and return info if client is falsy', (done) => {
db.info(null, (err, info) => {
2017-05-19 20:24:54 -04:00
assert.ifError(err);
assert(info);
2017-05-19 20:24:54 -04:00
done();
});
});
});
2021-02-04 00:01:39 -07:00
describe('checkCompatibility', () => {
it('should not throw', (done) => {
2017-05-19 20:24:54 -04:00
db.checkCompatibility(done);
});
2021-02-04 00:01:39 -07:00
it('should return error with a too low version', (done) => {
2021-02-04 00:06:15 -07:00
const dbName = nconf.get('database');
2017-05-19 20:24:54 -04:00
if (dbName === 'redis') {
2021-02-04 00:01:39 -07:00
db.checkCompatibilityVersion('2.4.0', (err) => {
2017-05-19 20:24:54 -04:00
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') {
2021-02-04 00:01:39 -07:00
db.checkCompatibilityVersion('1.8.0', (err) => {
2017-05-19 20:24:54 -04:00
assert.equal(err.message, 'The `mongodb` package is out-of-date, please run `./nodebb setup` again.');
done();
});
} else if (dbName === 'postgres') {
2021-02-04 00:01:39 -07:00
db.checkCompatibilityVersion('6.3.0', (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');
});