From 55b337eefcd9d393c0be8df526f0ea1ee9b20376 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Mon, 3 Oct 2016 13:38:55 -0700 Subject: [PATCH] test app clone --- cloudron.js | 16 ++++++++++++++++ test/new-user-test.js | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/cloudron.js b/cloudron.js index 963aa9c..74d6120 100644 --- a/cloudron.js +++ b/cloudron.js @@ -233,6 +233,22 @@ Cloudron.prototype.configureApp = function (appId, newLocation, altDomain /* opt console.log('App is reachable'.green); }; +Cloudron.prototype.cloneApp = function (appId, newLocation, portBindings) { + portBindings = portBindings || null; + + var data = { location: newLocation, password: this._credentials.password, portBindings: portBindings }; + + var res = request.post(this._origin + '/api/v1/apps/' + appId + '/clone').query({ access_token: this._credentials.accessToken }).send(data).end(); + common.verifyResponse2xx(res, 'App could not be clone'); + + console.log('App cloned to different location'.green); + var app = this.waitForApp(appId); + + res = request.get('https://' + app.fqdn).end(); + common.verifyResponse2xx(res, 'App is unreachable'); + console.log('App is reachable'.green); +}; + Cloudron.prototype.uninstallApp = function (appId) { process.stdout.write('Uninstalling app'); var res = request.post(this._origin + '/api/v1/apps/' + appId + '/uninstall').query({ access_token: this._credentials.accessToken }).send({ password: this._credentials.password }).end(); diff --git a/test/new-user-test.js b/test/new-user-test.js index dd4cb8a..b5ed5e0 100644 --- a/test/new-user-test.js +++ b/test/new-user-test.js @@ -95,6 +95,10 @@ describe('Appstore new user flow', function () { cloudron.configureApp(appId, location); }); + it('can clone app', function () { + cloudron.cloneApp(appId, location + 'clone'); + }); + it('can uninstall app', function () { cloudron.uninstallApp(appId); });