test app restore
This commit is contained in:
parent
ccb2f48523
commit
3e51cc8d32
31
cloudron.js
31
cloudron.js
@ -257,7 +257,36 @@ Cloudron.prototype.updateApp = function (appId, manifestOrAppstoreId) {
|
||||
|
||||
res = request.get('https://' + app.fqdn).end();
|
||||
common.verifyResponse2xx(res, 'App is unreachable');
|
||||
console.log('App updated to '.green);
|
||||
console.log('App updated'.green);
|
||||
};
|
||||
|
||||
Cloudron.prototype.restoreApp = function (appId, backup) {
|
||||
process.stdout.write('Trying to restore to %j', backup);
|
||||
|
||||
var data = {
|
||||
backupId: backup.id
|
||||
};
|
||||
|
||||
var res = request.post(this._origin + '/api/v1/apps/' + appId + '/restore')
|
||||
.query({ access_token: this._credentials.accessToken })
|
||||
.send(data)
|
||||
.end();
|
||||
common.verifyResponse2xx(res, 'Could not restore');
|
||||
|
||||
console.log('Restore started'.green);
|
||||
|
||||
var app = this.waitForApp(appId, backup.version);
|
||||
debug('App is running'.green);
|
||||
|
||||
res = request.get('https://' + app.fqdn).end();
|
||||
common.verifyResponse2xx(res, 'App is unreachable');
|
||||
console.log('App restored'.green);
|
||||
};
|
||||
|
||||
Cloudron.prototype.listAppBackups = function (appId) {
|
||||
var res = request.get(this._origin + '/api/v1/apps/' + appId + '/backups').end();
|
||||
common.verifyResponse2xx(res, 'Could not list backups');
|
||||
return res.body.backups;
|
||||
};
|
||||
|
||||
Cloudron.prototype.update = function (toVersion) {
|
||||
|
@ -1,11 +1,12 @@
|
||||
/*
|
||||
* This tests an app update on the cloudron. There are
|
||||
* This tests an app update and then a restore on the cloudron. There are
|
||||
* two versions of haste in the staging appstore
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var AppStore = require('../appstore.js'),
|
||||
assert = require('assert'),
|
||||
Cloudron = require('../cloudron.js'),
|
||||
common = require('../common.js');
|
||||
|
||||
@ -62,6 +63,17 @@ describe('Application update test', function () {
|
||||
cloudron.updateApp(appId, APP_ID + '@' + APP_NEW_VERSION);
|
||||
});
|
||||
|
||||
var backups;
|
||||
it('can list the backups', function () {
|
||||
backups = cloudron.listAppBackups(appId, APP_ID + '@' + APP_NEW_VERSION);
|
||||
assert(backups.length).to.be(1);
|
||||
assert(backups[0].version).to.be(APP_OLD_VERSION);
|
||||
});
|
||||
|
||||
it('can restore app to previous version', function () {
|
||||
cloudron.restoreApp(appId, backups[0]);
|
||||
});
|
||||
|
||||
it('can uninstall app', function () {
|
||||
cloudron.uninstallApp(appId);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user