fix volume test

This commit is contained in:
Girish Ramakrishnan
2021-05-17 16:23:24 -07:00
parent 124954d490
commit c7474511aa
3 changed files with 12 additions and 6 deletions
+2 -1
View File
@@ -12,6 +12,7 @@ exports = module.exports = {
const assert = require('assert'),
BoxError = require('./boxerror.js'),
collectd = require('./collectd.js'),
constants = require('./constants.js'),
database = require('./database.js'),
debug = require('debug')('box:volumes'),
ejs = require('ejs'),
@@ -59,7 +60,7 @@ function validateHostPath(hostPath, mountType) {
if (!allowedPaths.some(p => hostPath.startsWith(p))) return new BoxError(BoxError.BAD_FIELD, 'hostPath must be under /mnt, /media, /opt or /srv', { field: 'hostPath' });
if (mountType === 'noop') { // we expect user to have already mounted this
if (!constants.TEST && mountType === 'noop') { // we expect user to have already mounted this
const stat = safe.fs.lstatSync(hostPath);
if (!stat) return new BoxError(BoxError.BAD_FIELD, 'hostPath does not exist. Please create it on the server first', { field: 'hostPath' });
if (!stat.isDirectory()) return new BoxError(BoxError.BAD_FIELD, 'hostPath is not a directory', { field: 'hostPath' });