36aa641cb9
also, set no-use-before-define in linter
69 lines
2.3 KiB
JavaScript
69 lines
2.3 KiB
JavaScript
/* global it:false */
|
|
|
|
import apptask from '../apptask.js';
|
|
import common from './common.js';
|
|
import expect from 'expect.js';
|
|
import fs from 'node:fs';
|
|
import paths from '../paths.js';
|
|
import safe from 'safetydance';
|
|
|
|
/* global describe:false */
|
|
/* global before:false */
|
|
/* global after:false */
|
|
|
|
describe('apptask', function () {
|
|
const { setup, cleanup, app } = common;
|
|
|
|
before(setup);
|
|
after(cleanup);
|
|
|
|
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) ', 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) ', 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', async function () {
|
|
const badApp = Object.assign({ }, app);
|
|
badApp.manifest = { };
|
|
|
|
const [error] = await safe(apptask._verifyManifest(badApp.manifest));
|
|
expect(error).to.be.ok();
|
|
});
|
|
|
|
it('fails on bad manifest', async function () {
|
|
const badApp = Object.assign({ }, app);
|
|
badApp.manifest = Object.assign({ }, app.manifest);
|
|
delete badApp.manifest.httpPort;
|
|
|
|
const [error] = await safe(apptask._verifyManifest(badApp.manifest));
|
|
expect(error).to.be.ok();
|
|
});
|
|
|
|
it('barfs on incompatible manifest', async function () {
|
|
const badApp = Object.assign({ }, app);
|
|
badApp.manifest = Object.assign({ }, app.manifest);
|
|
badApp.manifest.maxBoxVersion = '0.0.0'; // max box version is too small
|
|
|
|
const [error] = await safe(apptask._verifyManifest(badApp.manifest));
|
|
expect(error).to.be.ok();
|
|
});
|
|
|
|
it('verifies manifest', async function () {
|
|
const goodApp = Object.assign({ }, app);
|
|
|
|
await apptask._verifyManifest(goodApp.manifest);
|
|
});
|
|
});
|