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);
var server, browser = new Builder().forBrowser('chrome').build();
var LOCATION = 'test';
var SSH_PORT = 29420;
var repodir = '/tmp/testrepo';
var app, reponame = 'testrepo';
var username = process.env.USERNAME;
@ -210,7 +211,7 @@ return done();
}).then(function () {
return browser.findElement(by.id('repo-clone-url')).getAttribute('value');
}).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();
});
}
@ -219,14 +220,14 @@ return done();
rimraf.sync(repodir);
var env = Object.create(process.env);
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();
}
function pushFile(done) {
var env = Object.create(process.env);
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 });
rimraf.sync('/tmp/testrepo');
done();
@ -254,7 +255,7 @@ return 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"]'));
return browser.executeScript('arguments[0].scrollIntoView(true)', button);
}).then(function () {
@ -275,7 +276,7 @@ return done();
it('can login', function (done) {
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,
password: password
}).end(function (error, result) {
@ -284,7 +285,7 @@ return done();
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) {
if (error) return done(error);
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 () {
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);
@ -380,7 +381,7 @@ return done();
// check if the _first_ login via email succeeds
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'));
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
@ -399,7 +400,7 @@ return done();
// 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' });
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);