From a03fb9225360308e0dc769df1ecad8033b70d17d Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Mon, 7 Aug 2017 11:16:29 -0700 Subject: [PATCH] Add update test --- test/test.js | 78 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 23 deletions(-) diff --git a/test/test.js b/test/test.js index 42d6968..cfa9a5d 100755 --- a/test/test.js +++ b/test/test.js @@ -63,6 +63,14 @@ describe('Application life cycle test', function () { }, 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) { 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')); @@ -160,7 +168,7 @@ describe('Application life cycle test', function () { }); } - function checkGitClone(done) { + function cloneRepo(done) { rimraf.sync(repodir); var env = Object.create(process.env); env.GIT_SSH = __dirname + '/git_ssh_wrapper.sh'; @@ -168,6 +176,19 @@ describe('Application life cycle test', function () { 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 () { 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' }); }); - 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('can get app information', getAppInfo); it('can get the main page', function (done) { superagent.get('https://' + app.fqdn).end(function (error, result) { expect(error).to.be(null); @@ -226,17 +240,9 @@ describe('Application life cycle test', function () { it('displays correct clone url', checkCloneUrl); - it('can clone the url', checkGitClone); - - 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 clone the url', cloneRepo); + it('can add and push a file', pushFile); it('can edit file', editFile); 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', checkGitClone); - it('file exists in repo', function () { expect(fs.existsSync(repodir + '/newfile')).to.be(true); }); + it('can clone the url', cloneRepo); + it('file exists in repo', fileExists); it('backup app', function () { 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 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('move to different location', function () { @@ -271,7 +277,7 @@ describe('Application life cycle test', function () { it('can login', login); it('can get avatar', checkAvatar); 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('uninstall app', function () { @@ -292,4 +298,30 @@ describe('Application life cycle test', function () { 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' }); + }); });