diff options
-rw-r--r-- | README.md | 11 | ||||
-rw-r--r-- | package.json | 5 | ||||
-rwxr-xr-x | test/test.js | 82 |
3 files changed, 98 insertions, 0 deletions
@@ -42,3 +42,14 @@ Put some files: | |||
42 | 42 | ||
43 | surfer put [file] | 43 | surfer put [file] |
44 | 44 | ||
45 | ## Testing | ||
46 | |||
47 | The e2e tests are located in the `test/` folder and require [nodejs](http://nodejs.org/). They are creating a fresh build, install the app on your Cloudron, perform tests, backup, restore and test if the files are still ok. | ||
48 | |||
49 | ``` | ||
50 | cd surfer/test | ||
51 | |||
52 | npm install | ||
53 | USERNAME=<cloudron username> PASSWORD=<cloudron password> mocha --bail test.js | ||
54 | ``` | ||
55 | |||
diff --git a/package.json b/package.json index 6b48a0b..d0607f6 100644 --- a/package.json +++ b/package.json | |||
@@ -39,5 +39,10 @@ | |||
39 | "safetydance": "0.0.16", | 39 | "safetydance": "0.0.16", |
40 | "superagent": "^1.2.0", | 40 | "superagent": "^1.2.0", |
41 | "underscore": "^1.8.3" | 41 | "underscore": "^1.8.3" |
42 | }, | ||
43 | "devDependencies": { | ||
44 | "expect.js": "^0.3.1", | ||
45 | "mocha": "^2.3.4", | ||
46 | "rimraf": "^2.4.4" | ||
42 | } | 47 | } |
43 | } | 48 | } |
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 | }); | ||