Files
cloudron-box/src/test/system-test.js

55 lines
1.7 KiB
JavaScript
Raw Normal View History

2016-01-25 16:03:12 -08:00
/* jslint node:true */
/* global it:false */
/* global describe:false */
/* global before:false */
/* global after:false */
'use strict';
2021-06-03 12:20:44 -07:00
const common = require('./common.js'),
2019-11-21 12:58:06 -08:00
expect = require('expect.js'),
system = require('../system.js');
2016-01-25 16:03:12 -08:00
2019-11-21 12:58:06 -08:00
describe('System', function () {
2021-08-13 10:41:10 -07:00
const { setup, cleanup } = common;
before(setup);
after(cleanup);
2016-01-25 16:03:12 -08:00
2021-08-25 19:41:46 -07:00
it('can get disks', async function () {
// does not work on archlinux 8!
if (require('child_process').execSync('uname -a').toString().indexOf('-arch') !== -1) return;
2021-08-25 19:41:46 -07:00
const disks = await system.getDisks();
expect(disks).to.be.ok();
2022-11-04 15:09:37 +01:00
expect(Object.keys(disks).some(fs => disks[fs].mountpoint === '/')).to.be.ok();
});
it('can get swaps', async function () {
// does not work on archlinux 8!
if (require('child_process').execSync('uname -a').toString().indexOf('-arch') !== -1) return;
const swaps = await system.getSwaps();
expect(swaps).to.be.ok();
expect(Object.keys(swaps).some(n => swaps[n].type === 'partition')).to.be.ok();
2019-08-19 13:50:44 -07:00
});
2021-08-25 19:41:46 -07:00
it('can check for disk space', async function () {
// does not work on archlinux 8!
if (require('child_process').execSync('uname -a').toString().indexOf('-arch') !== -1) return;
2021-08-25 19:41:46 -07:00
await system.checkDiskSpace();
2016-01-25 16:03:12 -08:00
});
2019-11-21 12:58:06 -08:00
2021-08-25 19:41:46 -07:00
it('can get memory', async function () {
const memory = await system.getMemory();
expect(memory.memory).to.be.a('number');
expect(memory.swap).to.be.a('number');
2019-11-21 12:58:06 -08:00
});
2022-10-11 22:58:12 +02:00
2022-10-12 10:30:02 +02:00
it('can get diskUsage', async function () {
const usage = await system.getDiskUsage();
expect(usage).to.be(null); // nothing cached
2022-10-11 22:58:12 +02:00
});
2016-01-25 16:03:12 -08:00
});