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
|
|
|
|
2024-11-30 11:46:28 +01:00
|
|
|
it('can get filesystems', async function () {
|
2021-09-16 15:20:26 +02:00
|
|
|
// does not work on archlinux 8!
|
|
|
|
|
if (require('child_process').execSync('uname -a').toString().indexOf('-arch') !== -1) return;
|
|
|
|
|
|
2024-11-30 11:46:28 +01:00
|
|
|
const disks = await system._getFilesystems();
|
2021-08-25 19:41:46 -07:00
|
|
|
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();
|
2023-12-03 15:05:26 +01:00
|
|
|
expect(Object.keys(swaps).some(n => swaps[n].type === 'partition' || swaps[n].type === 'file')).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 () {
|
2021-09-16 15:20:26 +02:00
|
|
|
// 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
|
|
|
|
2023-12-04 00:23:25 +01:00
|
|
|
it('can get CPUs', async function () {
|
|
|
|
|
const cpus = await system.getCpus();
|
|
|
|
|
expect(cpus).to.be.an(Array);
|
|
|
|
|
expect(cpus[0].model).to.be.a('string');
|
|
|
|
|
});
|
2023-12-04 00:31:18 +01:00
|
|
|
|
2023-12-04 01:09:42 +01:00
|
|
|
it('can get info', async function () {
|
|
|
|
|
const info = await system.getInfo();
|
2023-12-04 00:31:18 +01:00
|
|
|
|
2023-12-04 01:09:42 +01:00
|
|
|
expect(info.sysVendor).to.be.a('string');
|
|
|
|
|
expect(info.productName).to.be.a('string');
|
|
|
|
|
expect(info.uptimeSecs).to.be.a('number');
|
|
|
|
|
expect(info.rebootRequired).to.be.a('boolean');
|
2023-12-04 00:31:18 +01: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
|
|
|
});
|
2023-01-27 21:05:25 +01:00
|
|
|
|
|
|
|
|
it('can updateDiskUsage', async function () {
|
|
|
|
|
const usage = await system.updateDiskUsage(function () {});
|
|
|
|
|
const tmp = usage[Object.keys(usage)[0]];
|
|
|
|
|
|
|
|
|
|
expect(tmp.size).to.be.greaterThan(0);
|
|
|
|
|
expect(tmp.used).to.be.greaterThan(0);
|
|
|
|
|
expect(tmp.available).to.be.greaterThan(0);
|
|
|
|
|
expect(tmp.capacity).to.be.greaterThan(0);
|
|
|
|
|
expect(tmp.speed).to.be.a('number');
|
|
|
|
|
});
|
2016-01-25 16:03:12 -08:00
|
|
|
});
|