cloudron-e2e-test/test/app-update-test.js

78 lines
2.2 KiB
JavaScript

/*
* This tests an app update 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'),
request = require('superagent-sync');
require('colors');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
var BOX_VERSION = process.env.BOX_VERSION;
var APP_ID = 'com.hastebin.cloudronapp', APP_OLD_VERSION = '0.4.0', APP_NEW_VERSION = '0.4.1';
describe('Application update test', function () {
this.timeout(0);
var appStore = new AppStore('https://api.staging.cloudron.io');
var owner = common.getOwner();
var admin = common.getAdmin();
var cloudron, appId, box;
it('can login to the store', function () {
var accessToken = appStore.getAccessToken(owner);
appStore.setCredentials(owner.password, accessToken);
var adminAccessToken = appStore.getAccessToken(admin);
appStore.setAdminCredentials(admin.password, adminAccessToken);
});
it('can create a cloudron', function () {
box = appStore.createCloudron({
domain: common.cloudronDomain(__filename),
region: 'sfo1',
size: '1gb',
version: BOX_VERSION
});
box = appStore.waitForCloudron(box.id);
cloudron = new Cloudron(box);
});
it('can activate the box', function () {
cloudron.activate(owner);
});
it('can login to the box', function () {
var token = cloudron.getOauthToken(owner);
cloudron.setCredentials(owner.password, token);
});
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);
});
it('update the app', function () {
var manifest = appStore.getManifest(APP_ID, APP_NEW_VERSION);
cloudron.updateApp(appId, manifest);
});
it('can uninstall app', function () {
cloudron.uninstallApp(appId);
});
it('can delete the cloudron', function () {
appStore.deleteCloudron(box);
});
});