Revert "add volume support"

This reverts commit b8bb69f730.

Revert this for now, we will try a simpler non-object volume first
This commit is contained in:
Girish Ramakrishnan
2020-04-27 22:55:43 -07:00
parent cc8509f8eb
commit 2cdf68379b
20 changed files with 38 additions and 864 deletions
+4 -114
View File
@@ -23,7 +23,6 @@ var appdb = require('../appdb.js'),
taskdb = require('../taskdb.js'),
tokendb = require('../tokendb.js'),
userdb = require('../userdb.js'),
volumedb = require('../volumedb.js'),
_ = require('underscore');
var USER_0 = {
@@ -419,8 +418,7 @@ describe('database', function () {
dataDir: null,
tags: [],
label: null,
taskId: null,
volumeIds: []
taskId: null
};
it('cannot delete referenced domain', function (done) {
@@ -608,7 +606,7 @@ describe('database', function () {
});
it('can get all admins', function (done) {
userdb.getByRole('owner', function (error) {
userdb.getByRole('owner', function (error, all) {
expect(error).to.be.ok();
expect(error.reason).to.be(BoxError.NOT_FOUND);
done();
@@ -891,8 +889,7 @@ describe('database', function () {
dataDir: null,
tags: [],
label: null,
taskId: null,
volumeIds: []
taskId: null
};
var APP_1 = {
@@ -923,8 +920,7 @@ describe('database', function () {
dataDir: null,
tags: [],
label: null,
taskId: null,
volumeIds: []
taskId: null
};
before(function (done) {
@@ -1967,110 +1963,4 @@ describe('database', function () {
});
});
});
describe('volumes', function () {
before(function (done) {
done();
});
after(function (done) {
database._clear(done);
});
it('can add volume', function (done) {
volumedb.add('id1', 'myvolume', '/tmp/foo', function (error) {
expect(error).to.be(null);
done();
});
});
it('cannot add conflicting name', function (done) {
volumedb.add('someotherid', 'myvolume', '/tmp/bar', function (error) {
expect(error.reason).to.be(BoxError.ALREADY_EXISTS);
done();
});
});
it('cannot get random id', function (done) {
volumedb.get('randomid', function (error) {
expect(error.reason).to.be(BoxError.NOT_FOUND);
done();
});
});
it('can get existing id', function (done) {
volumedb.get('id1', function (error, result) {
expect(error).to.be(null);
expect(result.name).to.be('myvolume');
expect(result.hostPath).to.be('/tmp/foo');
done();
});
});
it('cannot update random id', function (done) {
volumedb.update('randomid', { name: 'theirvolume', hostPath: '/tmp/bar' }, function (error) {
expect(error.reason).to.be(BoxError.NOT_FOUND);
done();
});
});
it('can add another volume', function (done) {
volumedb.add('id2', 'myvolume2', '/tmp/foo2', function (error) {
expect(error).to.be(null);
done();
});
});
it('cannot update to existing path', function (done) {
volumedb.update('id1', { name: 'myvolume2', hostPath: '/tmp/foo' }, function (error) {
expect(error.reason).to.be(BoxError.ALREADY_EXISTS);
done();
});
});
it('can update existing id', function (done) {
volumedb.update('id1', { hostPath: '/tmp/bar' }, function (error) {
expect(error).to.be(null);
done();
});
});
it('can list', function (done) {
volumedb.list(function (error, result) {
expect(error).to.be(null);
expect(result.length).to.be(2);
expect(result[0].name).to.be('myvolume');
expect(result[0].hostPath).to.be('/tmp/bar');
expect(result[1].name).to.be('myvolume2');
expect(result[1].hostPath).to.be('/tmp/foo2');
done();
});
});
it('cannot delete random id', function (done) {
volumedb.del('randomid', function (error) {
expect(error.reason).to.be(BoxError.NOT_FOUND);
done();
});
});
it('can delete existing id', function (done) {
volumedb.del('id1', function (error) {
expect(error).to.be(null);
done();
});
});
});
});
-92
View File
@@ -1,92 +0,0 @@
/* jslint node:true */
/* global it:false */
/* global describe:false */
/* global before:false */
/* global after:false */
'use strict';
let async = require('async'),
BoxError = require('../boxerror.js'),
database = require('../database.js'),
expect = require('expect.js'),
volumes = require('../volumes.js');
const AUDIT_SOURCE = { ip: '1.2.3.4' };
function setup(done) {
async.series([
database.initialize,
database._clear,
], done);
}
function cleanup(done) {
async.series([
database._clear,
database.uninitialize
], done);
}
describe('volumes', function () {
before(setup);
after(cleanup);
let volumeId;
describe('add', function () {
it('cannot add invalid name', function (done) {
volumes.add('fan&', '/tmp/foo', AUDIT_SOURCE, function (error) {
expect(error.reason).to.be(BoxError.BAD_FIELD);
done();
});
});
it('cannot add invalid path', function (done) {
volumes.add('fan', '/tmp/foo', AUDIT_SOURCE, function (error) {
expect(error.reason).to.be(BoxError.BAD_FIELD);
done();
});
});
it('can add valid volume', function (done) {
volumes.add('cloudron-test', '/media/cloudron-test', AUDIT_SOURCE, function (error, result) {
expect(error).to.be(null);
expect(result).to.be.a('string');
volumeId = result;
done();
});
});
});
describe('list', function () {
it('can list volumes', function (done) {
volumes.list(function (error, results) {
expect(error).to.be(null);
expect(results.length).to.be(1);
expect(results[0].id).to.be(volumeId);
expect(results[0].name).to.be('cloudron-test');
expect(results[0].hostPath).to.be('/media/cloudron-test');
done();
});
});
});
describe('del', function () {
it('cannot remove random volume', function (done) {
volumes.del('random', AUDIT_SOURCE, function (error) {
expect(error.reason).to.be(BoxError.NOT_FOUND);
done();
});
});
it('cannot remove existing volume', function (done) {
volumes.del(volumeId, AUDIT_SOURCE, function (error) {
expect(error).to.be(null);
done();
});
});
});
});