]>
Commit | Line | Data |
---|---|---|
ebd7ed7a GR |
1 | #!/usr/bin/env node |
2 | ||
3 | 'use strict'; | |
4 | ||
5 | var execSync = require('child_process').execSync, | |
6 | expect = require('expect.js'), | |
7 | path = require('path'), | |
8 | superagent = require('superagent'); | |
9 | ||
10 | process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; | |
11 | ||
12 | describe('Application life cycle test', function () { | |
13 | this.timeout(0); | |
14 | var LOCATION = 'surfertest'; | |
15 | var app; | |
16 | var username = process.env.USERNAME; | |
17 | var password = process.env.PASSWORD; | |
18 | ||
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')); | |
22 | ||
23 | done(); | |
24 | }); | |
25 | ||
26 | after(function (done) { | |
27 | done(); | |
28 | }); | |
29 | ||
30 | xit('build app', function () { | |
31 | execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); | |
32 | }); | |
33 | ||
34 | it('install app', function () { | |
35 | execSync('cloudron install --new --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); | |
36 | }); | |
37 | ||
38 | it('can get app information', function () { | |
39 | var inspect = JSON.parse(execSync('cloudron inspect')); | |
40 | ||
41 | app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0]; | |
42 | ||
43 | expect(app).to.be.an('object'); | |
44 | }); | |
45 | ||
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); | |
50 | ||
51 | done(); | |
52 | }); | |
53 | }); | |
54 | ||
55 | it('can login using cli', function (done) { | |
56 | execSync(__dirname + '../cli/surfer.js login https://' + app.fqdn, { input: username + '\n' + password + '\n' }); | |
57 | done(); | |
58 | }); | |
59 | ||
60 | it('can upload file', function (done) { | |
61 | execSync(__dirname + '../cli/surfer.js put test.js'); | |
62 | done(); | |
63 | }); | |
64 | ||
65 | it('backup app', function () { | |
66 | execSync('cloudron backup --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); | |
67 | }); | |
68 | ||
69 | it('restore app', function () { | |
70 | execSync('cloudron restore --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); | |
71 | }); | |
72 | ||
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); | |
76 | done(); | |
77 | }); | |
78 | ||
79 | xit('uninstall app', function () { | |
80 | execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); | |
81 | }); | |
82 | }); |