Fix installation states

App operations can only be done in 'installed' or 'error' state.
If some other operation is in progress, you have to cancel it first.

This guarantees that the old app command got killed.
This commit is contained in:
Girish Ramakrishnan
2019-08-29 09:10:39 -07:00
parent 1faee00764
commit f3008064e4
4 changed files with 42 additions and 36 deletions

View File

@@ -228,6 +228,8 @@ function stopBox(done) {
}
describe('App API', function () {
let taskId = '';
before(startBox);
after(stopBox);
@@ -424,6 +426,7 @@ describe('App API', function () {
APP_ID = res.body.id;
expect(fake2.isDone()).to.be.ok();
expect(fake3.isDone()).to.be.ok();
taskId = res.body.taskId;
done();
});
});
@@ -500,6 +503,15 @@ describe('App API', function () {
});
});
it('can stop the task', function (done) {
superagent.post(SERVER_URL + '/api/v1/tasks/' + taskId + '/stop')
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(204);
setTimeout(done, 4000); // wait for it to really die
});
});
it('can uninstall app', function (done) {
var fake1 = nock(settings.apiServerOrigin()).get(function (uri) { return uri.indexOf('/api/v1/cloudronapps/') >= 0; }).reply(200, { });
var fake2 = nock(settings.apiServerOrigin()).delete(function (uri) { return uri.indexOf('/api/v1/cloudronapps/') >= 0; }).reply(204, { });