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

View File

@@ -35,31 +35,31 @@ describe('Volumes', function () {
after(cleanup);
it('cannot add bad name', async function () {
const [error] = await safe(volumes.add('music/is', '/tmp/music', AUDIT_SOURCE));
const [error] = await safe(volumes.add({ name: 'music/is', hostPath: '/tmp/music', mountType: 'noop', mountOptions: {} }, AUDIT_SOURCE));
if (!error) throw new Error('Expecting bad field error');
expect(error.reason).to.be(BoxError.BAD_FIELD);
});
it('cannot add bad path', async function () {
const [error] = await safe(volumes.add('music', '/tmp/music', AUDIT_SOURCE));
const [error] = await safe(volumes.add({ name: 'music', hostPath: '/tmp/music', mountType: 'noop', mountOptions: {} }, AUDIT_SOURCE));
if (!error) throw new Error('Expecting bad field error');
expect(error.reason).to.be(BoxError.BAD_FIELD);
});
let volume;
it('can add volume', async function () {
const id = await volumes.add('music', '/mnt/cloudron-test-music', AUDIT_SOURCE);
const id = await volumes.add({ name: 'music', hostPath: '/mnt/cloudron-test-music', mountType: 'noop', mountOptions: {} }, AUDIT_SOURCE);
expect(id).to.be.a('string');
volume = { id, name: 'music', hostPath: '/mnt/cloudron-test-music' };
});
it('cannot add duplicate path', async function () {
const [error] = await safe(volumes.add('music-dup', '/mnt/cloudron-test-music', AUDIT_SOURCE));
const [error] = await safe(volumes.add({ name: 'music-dup', hostPath: '/mnt/cloudron-test-music', mountType: 'noop', mountOptions: {} }, AUDIT_SOURCE));
expect(error.reason).to.be(BoxError.ALREADY_EXISTS);
});
it('cannot add duplicate name', async function () {
const [error] = await safe(volumes.add('music', '/media/cloudron-test-music', AUDIT_SOURCE));
const [error] = await safe(volumes.add({ name: 'music', hostPath: '/mnt/cloudron-test-music2', mountType: 'noop', mountOptions: {} }, AUDIT_SOURCE));
expect(error.reason).to.be(BoxError.ALREADY_EXISTS);
});