Make tests use a different port to avoid conflicts

This commit is contained in:
Johannes Zellner 2018-11-02 08:53:38 +01:00
parent 65bc13c2b7
commit 9971919cf9
1 changed files with 10 additions and 9 deletions

View File

@ -31,6 +31,7 @@ describe('Application life cycle test', function () {
this.timeout(0); this.timeout(0);
var server, browser = new Builder().forBrowser('chrome').build(); var server, browser = new Builder().forBrowser('chrome').build();
var LOCATION = 'test'; var LOCATION = 'test';
var SSH_PORT = 29420;
var repodir = '/tmp/testrepo'; var repodir = '/tmp/testrepo';
var app, reponame = 'testrepo'; var app, reponame = 'testrepo';
var username = process.env.USERNAME; var username = process.env.USERNAME;
@ -210,7 +211,7 @@ return done();
}).then(function () { }).then(function () {
return browser.findElement(by.id('repo-clone-url')).getAttribute('value'); return browser.findElement(by.id('repo-clone-url')).getAttribute('value');
}).then(function (cloneUrl) { }).then(function (cloneUrl) {
expect(cloneUrl).to.be('ssh://git@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git'); expect(cloneUrl).to.be(`ssh://git@${app.fqdn}:${SSH_PORT}/${username}/${reponame}.git`);
done(); done();
}); });
} }
@ -219,14 +220,14 @@ return done();
rimraf.sync(repodir); rimraf.sync(repodir);
var env = Object.create(process.env); var env = Object.create(process.env);
env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh'; env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh';
execSync('git clone ssh://git@' + app.fqdn + ':29418/' + username + '/' + reponame + '.git ' + repodir, { env: env }); execSync(`git clone ssh://git@${app.fqdn}:${SSH_PORT}/${username}/${reponame}.git ${repodir}`, { env: env });
done(); done();
} }
function pushFile(done) { function pushFile(done) {
var env = Object.create(process.env); var env = Object.create(process.env);
env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh'; env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh';
execSync('touch newfile && git add newfile && git commit -a -mx && git push ssh://git@' + app.fqdn + ':29418/' + username + '/' + reponame + ' master', execSync(`touch newfile && git add newfile && git commit -a -mx && git push ssh://git@${app.fqdn}:${SSH_PORT}/${username}/${reponame} master`,
{ env: env, cwd: repodir }); { env: env, cwd: repodir });
rimraf.sync('/tmp/testrepo'); rimraf.sync('/tmp/testrepo');
done(); done();
@ -254,7 +255,7 @@ return done();
} }
function sendMail(done) { function sendMail(done) {
browser.get('https://' + app.fqdn + '/admin/config').then(function () { browser.get(`https://${app.fqdn}/admin/config`).then(function () {
var button = browser.findElement(by.xpath('//button[@id="test-mail-btn"]')); var button = browser.findElement(by.xpath('//button[@id="test-mail-btn"]'));
return browser.executeScript('arguments[0].scrollIntoView(true)', button); return browser.executeScript('arguments[0].scrollIntoView(true)', button);
}).then(function () { }).then(function () {
@ -275,7 +276,7 @@ return done();
it('can login', function (done) { it('can login', function (done) {
var inspect = JSON.parse(execSync('cloudron inspect')); var inspect = JSON.parse(execSync('cloudron inspect'));
superagent.post('https://' + inspect.apiEndpoint + '/api/v1/developer/login').send({ superagent.post(`https://${inspect.apiEndpoint}/api/v1/developer/login`).send({
username: username, username: username,
password: password password: password
}).end(function (error, result) { }).end(function (error, result) {
@ -284,7 +285,7 @@ return done();
token = result.body.accessToken; token = result.body.accessToken;
superagent.get('https://' + inspect.apiEndpoint + '/api/v1/profile') superagent.get(`https://${inspect.apiEndpoint}/api/v1/profile`)
.query({ access_token: token }).end(function (error, result) { .query({ access_token: token }).end(function (error, result) {
if (error) return done(error); if (error) return done(error);
if (result.statusCode !== 200) return done(new Error('Get profile failed with status ' + result.statusCode)); if (result.statusCode !== 200) return done(new Error('Get profile failed with status ' + result.statusCode));
@ -296,7 +297,7 @@ return done();
}); });
it('install app', function () { it('install app', function () {
execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); execSync(`cloudron install --new --wait --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
}); });
it('can get app information', getAppInfo); it('can get app information', getAppInfo);
@ -380,7 +381,7 @@ return done();
// check if the _first_ login via email succeeds // check if the _first_ login via email succeeds
it('can login via email', function (done) { it('can login via email', function (done) {
execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); execSync(`cloudron install --new --wait --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
var inspect = JSON.parse(execSync('cloudron inspect')); var inspect = JSON.parse(execSync('cloudron inspect'));
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0]; app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
@ -399,7 +400,7 @@ return done();
// test update // test update
it('can install app', function () { it('can install app', function () {
execSync('cloudron install --new --wait --appstore-id ' + app.manifest.id + ' --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); execSync(`cloudron install --new --wait --appstore-id ${app.manifest.id} --location ${LOCATION} -p SSH_PORT=${SSH_PORT}`, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
}); });
it('can get app information', getAppInfo); it('can get app information', getAppInfo);