test install and update with id@version format

This commit is contained in:
Girish Ramakrishnan 2016-06-07 16:06:30 -07:00
parent e33e78be82
commit da5045537a
2 changed files with 15 additions and 9 deletions

View File

@ -230,9 +230,19 @@ Cloudron.prototype.uninstallApp = function (appId) {
assert(false, 'uninstallApp failed');
};
Cloudron.prototype.updateApp = function (appId, newManifest) {
Cloudron.prototype.updateApp = function (appId, manifestOrAppstoreId) {
process.stdout.write('Trying to update');
var res = request.post(this._origin + '/api/v1/apps/' + appId + '/update').query({ access_token: this._credentials.accessToken }).send({ password: this._credentials.password, manifest: newManifest }).end();
var data = {
password: this._credentials.password,
manifest: typeof manifestOrAppstoreId === 'object' ? manifestOrAppstoreId : null,
appStoreId: typeof manifestOrAppstoreId === 'string' ? manifestOrAppstoreId : null
};
var res = request.post(this._origin + '/api/v1/apps/' + appId + '/update')
.query({ access_token: this._credentials.accessToken })
.send(data)
.end();
common.verifyResponse2xx(res, 'Could not update');
console.log('Update started'.green);

View File

@ -6,10 +6,8 @@
'use strict';
var AppStore = require('../appstore.js'),
assert = require('assert'),
Cloudron = require('../cloudron.js'),
common = require('../common.js'),
request = require('superagent-sync');
common = require('../common.js');
require('colors');
@ -57,13 +55,11 @@ describe('Application update test', function () {
var location = 'test' + (Math.random() * 10000).toFixed();
it('can install app', function () {
var manifest = appStore.getManifest(APP_ID, APP_OLD_VERSION);
appId = cloudron.installApp(location, manifest);
appId = cloudron.installApp(location, APP_ID + '@' + APP_OLD_VERSION);
});
it('update the app', function () {
var manifest = appStore.getManifest(APP_ID, APP_NEW_VERSION);
cloudron.updateApp(appId, manifest);
cloudron.updateApp(appId, APP_ID + '@' + APP_NEW_VERSION);
});
it('can uninstall app', function () {