mirror of
https://git.cloudron.io/cloudron/mastodon-app.git
synced 2024-11-25 09:11:00 +00:00
add tests
This commit is contained in:
parent
3439deee04
commit
3f4604f965
3 changed files with 1199 additions and 0 deletions
1059
test/package-lock.json
generated
Normal file
1059
test/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
24
test/package.json
Normal file
24
test/package.json
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"name": "test",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "test.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"ejs": "^2.3.4",
|
||||
"expect.js": "^0.3.1",
|
||||
"mkdirp": "^0.5.1",
|
||||
"mocha": "^2.3.4",
|
||||
"rimraf": "^2.4.4",
|
||||
"selenium-server-standalone-jar": "^2.53.0",
|
||||
"selenium-webdriver": "^2.53.3",
|
||||
"superagent": "^1.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"chromedriver": "^2.37.0"
|
||||
}
|
||||
}
|
116
test/test.js
Executable file
116
test/test.js
Executable file
|
@ -0,0 +1,116 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
/* jslint node:true */
|
||||
/* global it:false */
|
||||
/* global xit:false */
|
||||
/* global describe:false */
|
||||
/* global before:false */
|
||||
/* global after:false */
|
||||
|
||||
'use strict';
|
||||
|
||||
require('chromedriver');
|
||||
|
||||
var execSync = require('child_process').execSync,
|
||||
expect = require('expect.js'),
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
superagent = require('superagent'),
|
||||
webdriver = require('selenium-webdriver');
|
||||
|
||||
var by = webdriver.By,
|
||||
Keys = webdriver.Key,
|
||||
until = webdriver.until;
|
||||
|
||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
||||
|
||||
describe('Application life cycle test', function () {
|
||||
this.timeout(0);
|
||||
|
||||
var chrome = require('selenium-webdriver/chrome');
|
||||
var server, browser = new chrome.Driver(), uploadedImageUrl;
|
||||
var username = process.env.USERNAME, password = process.env.PASSWORD;
|
||||
|
||||
before(function (done) {
|
||||
var seleniumJar= require('selenium-server-standalone-jar');
|
||||
var SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;
|
||||
server = new SeleniumServer(seleniumJar.path, { port: 4444 });
|
||||
server.start();
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
after(function (done) {
|
||||
browser.quit();
|
||||
server.stop();
|
||||
done();
|
||||
});
|
||||
|
||||
var LOCATION = 'test';
|
||||
var TIMEOUT = parseInt(process.env.TIMEOUT, 10) || 30000;
|
||||
var app;
|
||||
var email, token;
|
||||
|
||||
function waitForUrl(url) {
|
||||
return browser.wait(function () {
|
||||
return browser.getCurrentUrl().then(function (currentUrl) {
|
||||
return currentUrl === url;
|
||||
});
|
||||
}, TIMEOUT);
|
||||
}
|
||||
|
||||
xit('build app', function () {
|
||||
execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
});
|
||||
|
||||
it('install app', function () {
|
||||
execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
});
|
||||
|
||||
it('can get app information', function () {
|
||||
var inspect = JSON.parse(execSync('cloudron inspect'));
|
||||
|
||||
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
|
||||
|
||||
expect(app).to.be.an('object');
|
||||
});
|
||||
|
||||
it('backup app', function () {
|
||||
execSync('cloudron backup create --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
});
|
||||
|
||||
it('restore app', function () {
|
||||
execSync('cloudron restore --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
});
|
||||
|
||||
it('can restart app', function (done) {
|
||||
execSync('cloudron restart --wait --app ' + app.id);
|
||||
done();
|
||||
});
|
||||
|
||||
it('move to different location', function () {
|
||||
execSync('cloudron configure --wait --location ' + LOCATION + '2 --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
var inspect = JSON.parse(execSync('cloudron inspect'));
|
||||
app = inspect.apps.filter(function (a) { return a.location === LOCATION + '2'; })[0];
|
||||
expect(app).to.be.an('object');
|
||||
});
|
||||
|
||||
it('uninstall app', function () {
|
||||
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
});
|
||||
|
||||
// test update
|
||||
it('can install app', function () {
|
||||
execSync('cloudron install --new --wait --appstore-id ' + app.manifest.id + ' --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
var inspect = JSON.parse(execSync('cloudron inspect'));
|
||||
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
|
||||
expect(app).to.be.an('object');
|
||||
});
|
||||
it('can update', function () {
|
||||
execSync('cloudron install --wait --app ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
});
|
||||
|
||||
it('uninstall app', function () {
|
||||
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue