5 var execSync
= require('child_process').execSync
,
6 expect
= require('expect.js'),
7 path
= require('path'),
8 superagent
= require('superagent');
10 process
.env
.NODE_TLS_REJECT_UNAUTHORIZED
= '0';
12 describe('Application life cycle test', function () {
14 var LOCATION
= 'surfertest';
16 var username
= process
.env
.USERNAME
;
17 var password
= process
.env
.PASSWORD
;
19 before(function (done
) {
20 if (!process
.env
.USERNAME
) return done(new Error('USERNAME env var not set'));
21 if (!process
.env
.PASSWORD
) return done(new Error('PASSWORD env var not set'));
26 after(function (done
) {
30 xit('build app', function () {
31 execSync('cloudron build', { cwd: path
.resolve(__dirname
, '..'), stdio: 'inherit' });
34 it('install app', function () {
35 execSync('cloudron install --new --location ' + LOCATION
, { cwd: path
.resolve(__dirname
, '..'), stdio: 'inherit' });
38 it('can get app information', function () {
39 var inspect
= JSON
.parse(execSync('cloudron inspect'));
41 app
= inspect
.apps
.filter(function (a
) { return a
.location
=== LOCATION
; })[0];
43 expect(app
).to
.be
.an('object');
46 it('can get the main page', function (done
) {
47 superagent
.get('https://' + app
.fqdn
).end(function (error
, result
) {
48 expect(error
).to
.be(null);
49 expect(result
.status
).to
.eql(200);
55 it('can login using cli', function (done
) {
56 execSync(__dirname
+ '../cli/surfer.js login https://' + app
.fqdn
, { input: username
+ '\n' + password
+ '\n' });
60 it('can upload file', function (done
) {
61 execSync(__dirname
+ '../cli/surfer.js put test.js');
65 it('backup app', function () {
66 execSync('cloudron backup --app ' + app
.id
, { cwd: path
.resolve(__dirname
, '..'), stdio: 'inherit' });
69 it('restore app', function () {
70 execSync('cloudron restore --app ' + app
.id
, { cwd: path
.resolve(__dirname
, '..'), stdio: 'inherit' });
73 it('can get the uploaded file', function (done
) {
74 var testFile
= execSync(__dirname
+ '../cli/surfer.js get test.js').toString('utf8');
75 console
.log(testFile
);
79 xit('uninstall app', function () {
80 execSync('cloudron uninstall --app ' + app
.id
, { cwd: path
.resolve(__dirname
, '..'), stdio: 'inherit' });