test.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/env node
  2. 'use strict';
  3. var execSync = require('child_process').execSync,
  4. ejs = require('ejs'),
  5. expect = require('expect.js'),
  6. fs = require('fs'),
  7. mkdirp = require('mkdirp'),
  8. path = require('path'),
  9. rimraf = require('rimraf'),
  10. superagent = require('superagent');
  11. process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
  12. describe('Application life cycle test', function () {
  13. this.timeout(0);
  14. var LOCATION = 'test' + Date.now();
  15. var app;
  16. var username = process.env.USERNAME;
  17. var password = process.env.PASSWORD;
  18. it('build app', function () {
  19. execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
  20. });
  21. it('install app', function () {
  22. execSync('cloudron install --new --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
  23. });
  24. it('can get app information', function () {
  25. var inspect = JSON.parse(execSync('cloudron inspect'));
  26. app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
  27. expect(app).to.be.an('object');
  28. });
  29. it('can get the main page', function (done) {
  30. superagent.get('https://' + app.fqdn).end(function (error, result) {
  31. expect(error).to.be(null);
  32. expect(result.status).to.eql(200);
  33. done();
  34. });
  35. });
  36. it('backup app', function () {
  37. execSync('cloudron backup --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
  38. });
  39. it('restore app', function () {
  40. execSync('cloudron restore --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
  41. });
  42. it('uninstall app', function () {
  43. execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
  44. });
  45. });