add volume support

part of #668, #569
This commit is contained in:
Girish Ramakrishnan
2020-04-22 19:18:04 -07:00
parent b46d3e74d6
commit b8bb69f730
20 changed files with 864 additions and 38 deletions

View File

@@ -1479,6 +1479,52 @@ describe('App API', function () {
});
});
describe('volumes', function () {
let volumeId;
it('can add volume', function (done) {
superagent.post(SERVER_URL + '/api/v1/volumes')
.query({ access_token: token })
.send({ name: 'videos', hostPath: '/media/cloudron-test' })
.end(function (err, res) {
expect(res.statusCode).to.equal(201);
expect(res.body.id).to.be.a('string');
volumeId = res.body.id;
done();
});
});
it('can set volume', function (done) {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/volumes')
.query({ access_token: token })
.send({ volumes: [ {id: volumeId, readOnly: false} ] })
.end(function (err, res) {
expect(res.statusCode).to.equal(202);
taskId = res.body.taskId;
done();
});
});
it('wait for task', function (done) {
waitForTask(taskId, done);
});
it('did set volume', function (done) {
apps.get(APP_ID, function (error, appEntry) {
if (error) return done(error);
docker.getContainer(appEntry.containerId).inspect(function (error, data) {
expect(error).to.not.be.ok();
expect(data.Mounts.filter(function (mount) { return mount.Destination === '/media/videos'; })[0].Type).to.eql('volume');
expect(data.Mounts.filter(function (mount) { return mount.Destination === '/media/videos'; })[0].Name).to.eql(volumeId);
expect(data.Mounts.filter(function (mount) { return mount.Destination === '/media/videos'; })[0].RW).to.eql(true);
done();
});
});
});
});
describe('start/stop', function () {
it('non admin cannot stop app', function (done) {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/stop')