2015-07-20 00:09:47 -07:00
|
|
|
/* global it:false */
|
|
|
|
|
/* global describe:false */
|
|
|
|
|
/* global before:false */
|
|
|
|
|
/* global after:false */
|
|
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
2021-06-03 12:20:44 -07:00
|
|
|
const apptask = require('../apptask.js'),
|
|
|
|
|
common = require('./common.js'),
|
2015-07-20 00:09:47 -07:00
|
|
|
expect = require('expect.js'),
|
|
|
|
|
fs = require('fs'),
|
|
|
|
|
paths = require('../paths.js'),
|
|
|
|
|
_ = require('underscore');
|
|
|
|
|
|
2021-06-03 12:20:44 -07:00
|
|
|
const { APP } = common;
|
2015-07-20 00:09:47 -07:00
|
|
|
|
|
|
|
|
describe('apptask', function () {
|
2021-06-03 12:20:44 -07:00
|
|
|
before(common.setup);
|
|
|
|
|
after(common.cleanup);
|
2015-07-20 00:09:47 -07:00
|
|
|
|
|
|
|
|
it('create volume', function (done) {
|
2018-09-14 10:18:43 -07:00
|
|
|
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);
|
2015-07-20 00:09:47 -07:00
|
|
|
expect(error).to.be(null);
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2017-09-07 15:43:57 -07:00
|
|
|
it('delete volume - removeDirectory (false) ', function (done) {
|
2018-09-14 10:18:43 -07:00
|
|
|
apptask._deleteAppDir(APP, { removeDirectory: false }, function (error) {
|
2017-09-07 15:43:57 -07:00
|
|
|
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 (true) ', function (done) {
|
2018-09-14 10:18:43 -07:00
|
|
|
apptask._deleteAppDir(APP, { removeDirectory: true }, function (error) {
|
2017-09-07 15:43:57 -07:00
|
|
|
expect(!fs.existsSync(paths.APPS_DATA_DIR + '/' + APP.id)).to.be(true);
|
2015-07-20 00:09:47 -07:00
|
|
|
expect(error).to.be(null);
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('barfs on empty manifest', function (done) {
|
|
|
|
|
var badApp = _.extend({ }, APP);
|
|
|
|
|
badApp.manifest = { };
|
|
|
|
|
|
2017-10-12 17:46:15 -07:00
|
|
|
apptask._verifyManifest(badApp.manifest, function (error) {
|
2015-07-20 00:09:47 -07:00
|
|
|
expect(error).to.be.ok();
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2019-11-19 17:36:05 -08:00
|
|
|
it('fails on bad manifest', function (done) {
|
2015-07-20 00:09:47 -07:00
|
|
|
var badApp = _.extend({ }, APP);
|
|
|
|
|
badApp.manifest = _.extend({ }, APP.manifest);
|
2019-11-19 17:36:05 -08:00
|
|
|
delete badApp.manifest.httpPort;
|
2015-07-20 00:09:47 -07:00
|
|
|
|
2017-10-12 17:46:15 -07:00
|
|
|
apptask._verifyManifest(badApp.manifest, function (error) {
|
2015-07-20 00:09:47 -07:00
|
|
|
expect(error).to.be.ok();
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('barfs on incompatible manifest', function (done) {
|
|
|
|
|
var badApp = _.extend({ }, APP);
|
|
|
|
|
badApp.manifest = _.extend({ }, APP.manifest);
|
|
|
|
|
badApp.manifest.maxBoxVersion = '0.0.0'; // max box version is too small
|
|
|
|
|
|
2017-10-12 17:46:15 -07:00
|
|
|
apptask._verifyManifest(badApp.manifest, function (error) {
|
2015-07-20 00:09:47 -07:00
|
|
|
expect(error).to.be.ok();
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('verifies manifest', function (done) {
|
|
|
|
|
var goodApp = _.extend({ }, APP);
|
|
|
|
|
|
2017-10-12 17:46:15 -07:00
|
|
|
apptask._verifyManifest(goodApp.manifest, function (error) {
|
2015-07-20 00:09:47 -07:00
|
|
|
expect(error).to.be(null);
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|