add docker disk usage tests
This commit is contained in:
@@ -10,6 +10,8 @@ const constants = require('../../constants.js'),
|
||||
expect = require('expect.js'),
|
||||
http = require('http'),
|
||||
os = require('os'),
|
||||
paths = require('../../paths.js'),
|
||||
safe = require('safetydance'),
|
||||
superagent = require('superagent'),
|
||||
settings = require('../../settings.js');
|
||||
|
||||
@@ -382,6 +384,8 @@ describe('Cloudron API', function () {
|
||||
|
||||
describe('disk usage', function () {
|
||||
it('get succeeds with no cache', async function () {
|
||||
safe.fs.unlinkSync(paths.DISK_USAGE_FILE);
|
||||
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/cloudron/disk_usage`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({});
|
||||
@@ -405,7 +409,17 @@ describe('Cloudron API', function () {
|
||||
.send({});
|
||||
|
||||
expect(response.statusCode).to.equal(200);
|
||||
console.log(response.body);
|
||||
expect(response.body.usage.ts).to.be.a('number');
|
||||
|
||||
const filesystems = Object.keys(response.body.usage.disks);
|
||||
let dockerUsage = null;
|
||||
for (const fs of filesystems) {
|
||||
for (const content of response.body.usage.disks[fs].contents) {
|
||||
if (content.id === 'docker') dockerUsage = content;
|
||||
}
|
||||
}
|
||||
expect(dockerUsage).to.be.ok();
|
||||
expect(dockerUsage.usage).to.be.a('number');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user