test.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. webdriver = require('selenium-webdriver');
  12. process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
  13. describe('Application life cycle test', function () {
  14. this.timeout(0);
  15. before(function () {
  16. var seleniumJar= require('selenium-server-standalone-jar');
  17. var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;
  18. var server = new SeleniumServer(seleniumJar.path, { port: 4444 });
  19. server.start();
  20. });
  21. var LOCATION = 'test' + Date.now();
  22. var app;
  23. var username = process.env.USERNAME;
  24. var password = process.env.PASSWORD;
  25. it('build app', function () {
  26. execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
  27. });
  28. it('install app', function () {
  29. execSync('cloudron install --new --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
  30. });
  31. it('can get app information', function () {
  32. var inspect = JSON.parse(execSync('cloudron inspect'));
  33. app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
  34. expect(app).to.be.an('object');
  35. });
  36. it('can get the main page', function (done) {
  37. superagent.get('https://' + app.fqdn).end(function (error, result) {
  38. expect(error).to.be(null);
  39. expect(result.status).to.eql(200);
  40. done();
  41. });
  42. });
  43. it('backup app', function () {
  44. execSync('cloudron backup --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
  45. });
  46. it('restore app', function () {
  47. execSync('cloudron restore --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
  48. });
  49. it('uninstall app', function () {
  50. execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
  51. });
  52. });