Add update test

This commit is contained in:
Girish Ramakrishnan 2017-08-07 11:16:29 -07:00
parent c636d1dd87
commit a03fb92253

View file

@ -63,6 +63,14 @@ describe('Application life cycle test', function () {
}, TIMEOUT).then(function () { done(); }); }, TIMEOUT).then(function () { done(); });
} }
function getAppInfo() {
var inspect = JSON.parse(execSync('cloudron inspect'));
app = inspect.apps.filter(function (a) { return a.location === LOCATION; })[0];
expect(app).to.be.an('object');
}
function setAvatar(done) { function setAvatar(done) {
browser.get('https://' + app.fqdn + '/user/settings/avatar').then(function () { browser.get('https://' + app.fqdn + '/user/settings/avatar').then(function () {
return browser.findElement(by.xpath('//input[@type="file" and @name="avatar"]')).sendKeys(path.resolve(__dirname, '../logo.png')); return browser.findElement(by.xpath('//input[@type="file" and @name="avatar"]')).sendKeys(path.resolve(__dirname, '../logo.png'));
@ -160,7 +168,7 @@ describe('Application life cycle test', function () {
}); });
} }
function checkGitClone(done) { function cloneRepo(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';
@ -168,6 +176,19 @@ describe('Application life cycle test', function () {
done(); 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',
{ env: env, cwd: repodir });
rimraf.sync('/tmp/testrepo');
done();
}
function fileExists() {
expect(fs.existsSync(repodir + '/newfile')).to.be(true);
}
xit('build app', function () { xit('build app', function () {
execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); execSync('cloudron build', { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
}); });
@ -199,14 +220,7 @@ describe('Application life cycle test', function () {
execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); execSync('cloudron install --new --wait --location ' + LOCATION, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
}); });
it('can get app information', function () { it('can get app information', getAppInfo);
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 get the main page', function (done) { it('can get the main page', function (done) {
superagent.get('https://' + app.fqdn).end(function (error, result) { superagent.get('https://' + app.fqdn).end(function (error, result) {
expect(error).to.be(null); expect(error).to.be(null);
@ -226,17 +240,9 @@ describe('Application life cycle test', function () {
it('displays correct clone url', checkCloneUrl); it('displays correct clone url', checkCloneUrl);
it('can clone the url', checkGitClone); it('can clone the url', cloneRepo);
it('can add and push a file', function (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',
{ env: env, cwd: repodir });
rimraf.sync('/tmp/testrepo');
done();
});
it('can add and push a file', pushFile);
it('can edit file', editFile); it('can edit file', editFile);
it('can restart app', function (done) { it('can restart app', function (done) {
@ -245,8 +251,8 @@ describe('Application life cycle test', function () {
}); });
it('can clone the url', checkCloneUrl); it('can clone the url', checkCloneUrl);
it('can clone the url', checkGitClone); it('can clone the url', cloneRepo);
it('file exists in repo', function () { expect(fs.existsSync(repodir + '/newfile')).to.be(true); }); it('file exists in repo', fileExists);
it('backup app', function () { it('backup app', function () {
execSync('cloudron backup create --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); execSync('cloudron backup create --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
@ -257,7 +263,7 @@ describe('Application life cycle test', function () {
}); });
it('can get avatar', checkAvatar); it('can get avatar', checkAvatar);
it('can clone the url', checkGitClone); it('can clone the url', cloneRepo);
it('file exists in repo', function () { expect(fs.existsSync(repodir + '/newfile')).to.be(true); }); it('file exists in repo', function () { expect(fs.existsSync(repodir + '/newfile')).to.be(true); });
it('move to different location', function () { it('move to different location', function () {
@ -271,7 +277,7 @@ describe('Application life cycle test', function () {
it('can login', login); it('can login', login);
it('can get avatar', checkAvatar); it('can get avatar', checkAvatar);
it('displays correct clone url', checkCloneUrl); it('displays correct clone url', checkCloneUrl);
it('can clone the url', checkGitClone); it('can clone the url', cloneRepo);
it('file exists in repo', function () { expect(fs.existsSync(repodir + '/newfile')).to.be(true); }); it('file exists in repo', function () { expect(fs.existsSync(repodir + '/newfile')).to.be(true); });
it('uninstall app', function () { it('uninstall app', function () {
@ -292,4 +298,30 @@ describe('Application life cycle test', function () {
done(); 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' });
});
it('can get app information', getAppInfo);
it('can login', login);
it('can set avatar', setAvatar);
it('can get avatar', checkAvatar);
it('can add public key', addPublicKey);
it('can create repo', createRepo);
it('can clone the url', cloneRepo);
it('can add and push a file', pushFile);
it('can update', function () {
execSync('cloudron install --wait --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
});
it('can get avatar', checkAvatar);
it('can clone the url', cloneRepo);
it('file exists in cloned repo', fileExists);
it('uninstall app', function () {
execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' });
});
}); });