2015-07-20 00:09:47 -07:00
|
|
|
/* global it:false */
|
|
|
|
|
/* global describe:false */
|
|
|
|
|
/* global before:false */
|
|
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
2021-08-20 09:19:44 -07:00
|
|
|
const database = require('../database'),
|
|
|
|
|
expect = require('expect.js');
|
2018-01-26 18:32:13 +01:00
|
|
|
|
2015-07-20 00:09:47 -07:00
|
|
|
describe('database', function () {
|
2021-08-20 09:19:44 -07:00
|
|
|
describe('init', function () {
|
|
|
|
|
it('can init database', async function () {
|
|
|
|
|
await database.initialize();
|
2015-07-20 00:09:47 -07:00
|
|
|
});
|
|
|
|
|
|
2021-08-20 09:19:44 -07:00
|
|
|
it('can clear database', async function () {
|
|
|
|
|
await database._clear();
|
2015-07-20 00:09:47 -07:00
|
|
|
});
|
|
|
|
|
|
2021-08-20 09:19:44 -07:00
|
|
|
it('can uninitialize database', async function () {
|
|
|
|
|
await database.uninitialize();
|
2015-07-20 00:09:47 -07:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2017-11-22 10:57:56 -08:00
|
|
|
describe('importFromFile', function () {
|
2021-08-20 09:19:44 -07:00
|
|
|
before(async function () {
|
|
|
|
|
await database.initialize();
|
|
|
|
|
await database._clear();
|
2017-11-22 10:57:56 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('cannot import from non-existent file', function (done) {
|
|
|
|
|
database.importFromFile('/does/not/exist', function (error) {
|
|
|
|
|
expect(error).to.be.ok();
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2017-11-24 15:31:03 -08:00
|
|
|
it('can export to file', function (done) {
|
2019-05-07 15:31:32 +02:00
|
|
|
// arch only has maria db which lacks some mysqldump options we need, this is only here to allow running the tests :-/
|
|
|
|
|
if (require('child_process').execSync('/usr/bin/mysqldump --version').toString().indexOf('MariaDB') !== -1) return done();
|
|
|
|
|
|
2017-11-24 15:31:03 -08:00
|
|
|
database.exportToFile('/tmp/box.mysqldump', function (error) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('can import from file', function (done) {
|
2019-05-07 15:31:32 +02:00
|
|
|
// arch only has maria db which lacks some mysqldump options we need, this is only here to allow running the tests :-/
|
|
|
|
|
if (require('child_process').execSync('/usr/bin/mysqldump --version').toString().indexOf('MariaDB') !== -1) return done();
|
|
|
|
|
|
2017-11-24 15:31:03 -08:00
|
|
|
database.importFromFile('/tmp/box.mysqldump', function (error) {
|
2017-11-22 10:57:56 -08:00
|
|
|
expect(error).to.be(null);
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
2015-07-20 00:09:47 -07:00
|
|
|
});
|