You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nodebb/test/database.js

67 lines
1.7 KiB
JavaScript

'use strict';
const assert = require('assert');
const nconf = require('nconf');
const db = require('./mocks/databasemock');
describe('Test database', () => {
it('should work', () => {
assert.doesNotThrow(() => {
8 years ago
require('./mocks/databasemock');
});
});
describe('info', () => {
it('should return info about database', (done) => {
db.info(db.client, (err, info) => {
8 years ago
assert.ifError(err);
assert(info);
done();
});
});
it('should not error and return info if client is falsy', (done) => {
db.info(null, (err, info) => {
8 years ago
assert.ifError(err);
assert(info);
8 years ago
done();
});
});
});
describe('checkCompatibility', () => {
it('should not throw', (done) => {
8 years ago
db.checkCompatibility(done);
});
it('should return error with a too low version', (done) => {
const dbName = nconf.get('database');
8 years ago
if (dbName === 'redis') {
db.checkCompatibilityVersion('2.4.0', (err) => {
8 years ago
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) => {
8 years ago
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();
});
8 years ago
}
});
});
8 years ago
10 years ago
require('./database/keys');
10 years ago
require('./database/list');
10 years ago
require('./database/sets');
10 years ago
require('./database/hash');
10 years ago
require('./database/sorted');
});