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'),
|
2021-09-16 13:59:03 -07:00
|
|
|
expect = require('expect.js'),
|
|
|
|
|
fs = require('fs'),
|
|
|
|
|
safe = require('safetydance');
|
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
|
|
|
});
|
|
|
|
|
|
2021-09-16 13:59:03 -07:00
|
|
|
it('cannot import from non-existent file', async function () {
|
|
|
|
|
const [error] = await safe(database.importFromFile('/does/not/exist'));
|
|
|
|
|
expect(error).to.be.ok();
|
2017-11-22 10:57:56 -08:00
|
|
|
});
|
|
|
|
|
|
2021-09-16 13:59:03 -07:00
|
|
|
it('can export to file', async function () {
|
|
|
|
|
await database.exportToFile('/tmp/box.mysqldump');
|
2017-11-24 15:31:03 -08:00
|
|
|
});
|
|
|
|
|
|
2021-09-16 13:59:03 -07:00
|
|
|
it('can import from file', async function () {
|
|
|
|
|
await database.importFromFile('/tmp/box.mysqldump');
|
2017-11-22 10:57:56 -08:00
|
|
|
});
|
|
|
|
|
});
|
2015-07-20 00:09:47 -07:00
|
|
|
});
|