diff options
author | Girish Ramakrishnan <girish@forwardbias.in> | 2015-11-27 15:11:30 -0800 |
---|---|---|
committer | Girish Ramakrishnan <girish@forwardbias.in> | 2015-11-27 15:21:07 -0800 |
commit | ebd7ed7a5a93ea8b55addef0175fc777f400b954 (patch) | |
tree | 9ba0123d758d05b0b2bf812b3f325e2e1b04a292 /test | |
parent | 20826700209d32826a8227b587f074c1826fc0f9 (diff) | |
download | Surfer-ebd7ed7a5a93ea8b55addef0175fc777f400b954.tar.gz Surfer-ebd7ed7a5a93ea8b55addef0175fc777f400b954.tar.zst Surfer-ebd7ed7a5a93ea8b55addef0175fc777f400b954.zip |
Add cloudron tests
Diffstat (limited to 'test')
-rwxr-xr-x | test/test.js | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/test/test.js b/test/test.js new file mode 100755 index 0000000..85c5c04 --- /dev/null +++ b/test/test.js | |||
@@ -0,0 +1,82 @@ | |||
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 | }); | ||