feat(host): /api/host CPU/mem/disk/net from /proc
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
22
tests/api/host.test.js
Normal file
22
tests/api/host.test.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { describe, it, expect, beforeAll } from 'vitest';
|
||||
import request from 'supertest';
|
||||
import { setup } from './helpers.js';
|
||||
|
||||
let app, ownerHeaders;
|
||||
beforeAll(async () => { ({ app, ownerHeaders } = await setup()); });
|
||||
|
||||
describe('host api', () => {
|
||||
it('401 without auth', async () => {
|
||||
expect((await request(app).get('/api/host')).status).toBe(401);
|
||||
});
|
||||
it('returns cpu/mem/disk/net shape', async () => {
|
||||
const res = await request(app).get('/api/host').set(ownerHeaders);
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.body.cpu_pct).toBeGreaterThanOrEqual(0);
|
||||
expect(res.body.cpu_pct).toBeLessThanOrEqual(100);
|
||||
expect(res.body.mem.total).toBeGreaterThan(0);
|
||||
expect(res.body.mem.used).toBeGreaterThanOrEqual(0);
|
||||
expect(res.body.disk).toHaveProperty('pct');
|
||||
expect(res.body.net).toHaveProperty('rx_bytes');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user