apptask: asyncify
This commit is contained in:
@@ -5,7 +5,9 @@
|
||||
'use strict';
|
||||
|
||||
const database = require('../database'),
|
||||
expect = require('expect.js');
|
||||
expect = require('expect.js'),
|
||||
fs = require('fs'),
|
||||
safe = require('safetydance');
|
||||
|
||||
describe('database', function () {
|
||||
describe('init', function () {
|
||||
@@ -28,32 +30,23 @@ describe('database', function () {
|
||||
await database._clear();
|
||||
});
|
||||
|
||||
it('cannot import from non-existent file', function (done) {
|
||||
database.importFromFile('/does/not/exist', function (error) {
|
||||
expect(error).to.be.ok();
|
||||
done();
|
||||
});
|
||||
it('cannot import from non-existent file', async function () {
|
||||
const [error] = await safe(database.importFromFile('/does/not/exist'));
|
||||
expect(error).to.be.ok();
|
||||
});
|
||||
|
||||
it('can export to file', function (done) {
|
||||
it('can export to file', async function () {
|
||||
// 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();
|
||||
if (!fs.readFileSync('/etc/lsb-release', 'utf8').includes('Ubuntu')) return;
|
||||
|
||||
database.exportToFile('/tmp/box.mysqldump', function (error) {
|
||||
expect(error).to.be(null);
|
||||
done();
|
||||
});
|
||||
await database.exportToFile('/tmp/box.mysqldump');
|
||||
});
|
||||
|
||||
it('can import from file', function (done) {
|
||||
it('can import from file', async function () {
|
||||
// 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();
|
||||
if (!fs.readFileSync('/etc/lsb-release', 'utf8').includes('Ubuntu')) return;
|
||||
|
||||
database.importFromFile('/tmp/box.mysqldump', function (error) {
|
||||
expect(error).to.be(null);
|
||||
done();
|
||||
});
|
||||
await database.importFromFile('/tmp/box.mysqldump');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user