[API] Fix bug
This commit is contained in:
parent
2012477c82
commit
a529b51c2d
|
@ -3,7 +3,7 @@
|
||||||
/**
|
/**
|
||||||
* Module dependencies
|
* Module dependencies
|
||||||
*/
|
*/
|
||||||
import DriveFile from './models/drive-file';
|
import DriveFile from '../models/drive-file';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get drive information
|
* Get drive information
|
||||||
|
@ -16,11 +16,11 @@ module.exports = (params, user) =>
|
||||||
new Promise(async (res, rej) =>
|
new Promise(async (res, rej) =>
|
||||||
{
|
{
|
||||||
// Fetch all files to calculate drive usage
|
// Fetch all files to calculate drive usage
|
||||||
const files = await DriveFile
|
const files = await DriveFile
|
||||||
.find({ user_id: user._id }, {
|
.find({ user_id: user._id }, {
|
||||||
datasize: true,
|
datasize: true,
|
||||||
_id: false
|
_id: false
|
||||||
});
|
});
|
||||||
|
|
||||||
// Calculate drive usage (in byte)
|
// Calculate drive usage (in byte)
|
||||||
const usage = files.map(file => file.datasize).reduce((x, y) => x + y, 0);
|
const usage = files.map(file => file.datasize).reduce((x, y) => x + y, 0);
|
||||||
|
|
16
test/api.js
16
test/api.js
|
@ -763,6 +763,22 @@ describe('API', () => {
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('drive', () => {
|
||||||
|
it('ドライブ情報を取得できる', () => new Promise(async (done) => {
|
||||||
|
const me = await insertSakurako();
|
||||||
|
const file = await insertDriveFile({
|
||||||
|
user_id: me._id,
|
||||||
|
datasize: 1024
|
||||||
|
});
|
||||||
|
request('/drive', {}, me).then(res => {
|
||||||
|
res.should.have.status(200);
|
||||||
|
res.body.should.be.a('object');
|
||||||
|
res.body.should.have.property('usage').eql(1024);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
describe('drive/files/create', () => {
|
describe('drive/files/create', () => {
|
||||||
it('ファイルを作成できる', () => new Promise(async (done) => {
|
it('ファイルを作成できる', () => new Promise(async (done) => {
|
||||||
const me = await insertSakurako();
|
const me = await insertSakurako();
|
||||||
|
|
Loading…
Reference in New Issue