apptask: asyncify
This commit is contained in:
+27
-44
@@ -10,6 +10,7 @@ const apptask = require('../apptask.js'),
|
||||
expect = require('expect.js'),
|
||||
fs = require('fs'),
|
||||
paths = require('../paths.js'),
|
||||
safe = require('safetydance'),
|
||||
_ = require('underscore');
|
||||
|
||||
describe('apptask', function () {
|
||||
@@ -18,70 +19,52 @@ describe('apptask', function () {
|
||||
before(setup);
|
||||
after(cleanup);
|
||||
|
||||
it('create volume', function (done) {
|
||||
apptask._createAppDir(app, function (error) {
|
||||
expect(fs.existsSync(paths.APPS_DATA_DIR + '/' + app.id)).to.be(true);
|
||||
expect(fs.existsSync(paths.APPS_DATA_DIR + '/' + app.id + '/data')).to.be(false);
|
||||
expect(error).to.be(null);
|
||||
done();
|
||||
});
|
||||
it('create volume', async function () {
|
||||
await apptask._createAppDir(app);
|
||||
expect(fs.existsSync(paths.APPS_DATA_DIR + '/' + app.id)).to.be(true);
|
||||
expect(fs.existsSync(paths.APPS_DATA_DIR + '/' + app.id + '/data')).to.be(false);
|
||||
});
|
||||
|
||||
it('delete volume - removeDirectory (false) ', function (done) {
|
||||
apptask._deleteAppDir(app, { removeDirectory: false }, function (error) {
|
||||
expect(fs.existsSync(paths.APPS_DATA_DIR + '/' + app.id)).to.be(true);
|
||||
expect(fs.readdirSync(paths.APPS_DATA_DIR + '/' + app.id).length).to.be(0); // empty
|
||||
expect(error).to.be(null);
|
||||
done();
|
||||
});
|
||||
it('delete volume - removeDirectory (false) ', async function () {
|
||||
await apptask._deleteAppDir(app, { removeDirectory: false });
|
||||
expect(fs.existsSync(paths.APPS_DATA_DIR + '/' + app.id)).to.be(true);
|
||||
expect(fs.readdirSync(paths.APPS_DATA_DIR + '/' + app.id).length).to.be(0); // empty
|
||||
});
|
||||
|
||||
it('delete volume - removeDirectory (true) ', function (done) {
|
||||
apptask._deleteAppDir(app, { removeDirectory: true }, function (error) {
|
||||
expect(!fs.existsSync(paths.APPS_DATA_DIR + '/' + app.id)).to.be(true);
|
||||
expect(error).to.be(null);
|
||||
done();
|
||||
});
|
||||
it('delete volume - removeDirectory (true) ', async function () {
|
||||
await apptask._deleteAppDir(app, { removeDirectory: true });
|
||||
expect(!fs.existsSync(paths.APPS_DATA_DIR + '/' + app.id)).to.be(true);
|
||||
});
|
||||
|
||||
it('barfs on empty manifest', function (done) {
|
||||
var badApp = _.extend({ }, app);
|
||||
it('barfs on empty manifest', async function () {
|
||||
const badApp = _.extend({ }, app);
|
||||
badApp.manifest = { };
|
||||
|
||||
apptask._verifyManifest(badApp.manifest, function (error) {
|
||||
expect(error).to.be.ok();
|
||||
done();
|
||||
});
|
||||
const [error] = await safe(apptask._verifyManifest(badApp.manifest));
|
||||
expect(error).to.be.ok();
|
||||
});
|
||||
|
||||
it('fails on bad manifest', function (done) {
|
||||
var badApp = _.extend({ }, app);
|
||||
it('fails on bad manifest', async function () {
|
||||
const badApp = _.extend({ }, app);
|
||||
badApp.manifest = _.extend({ }, app.manifest);
|
||||
delete badApp.manifest.httpPort;
|
||||
|
||||
apptask._verifyManifest(badApp.manifest, function (error) {
|
||||
expect(error).to.be.ok();
|
||||
done();
|
||||
});
|
||||
const [error] = await safe(apptask._verifyManifest(badApp.manifest));
|
||||
expect(error).to.be.ok();
|
||||
});
|
||||
|
||||
it('barfs on incompatible manifest', function (done) {
|
||||
var badApp = _.extend({ }, app);
|
||||
it('barfs on incompatible manifest', async function () {
|
||||
const badApp = _.extend({ }, app);
|
||||
badApp.manifest = _.extend({ }, app.manifest);
|
||||
badApp.manifest.maxBoxVersion = '0.0.0'; // max box version is too small
|
||||
|
||||
apptask._verifyManifest(badApp.manifest, function (error) {
|
||||
expect(error).to.be.ok();
|
||||
done();
|
||||
});
|
||||
const [error] = await safe(apptask._verifyManifest(badApp.manifest));
|
||||
expect(error).to.be.ok();
|
||||
});
|
||||
|
||||
it('verifies manifest', function (done) {
|
||||
var goodApp = _.extend({ }, app);
|
||||
it('verifies manifest', async function () {
|
||||
const goodApp = _.extend({ }, app);
|
||||
|
||||
apptask._verifyManifest(goodApp.manifest, function (error) {
|
||||
expect(error).to.be(null);
|
||||
done();
|
||||
});
|
||||
await apptask._verifyManifest(goodApp.manifest);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user