Add CPU usage to host inventory
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { validateInventory } from '../../src/lib/server/hosts/index.js';
|
||||
|
||||
describe('host CPU inventory', () => {
|
||||
it('accepts older agents without CPU usage', () => {
|
||||
expect(validateInventory({ cpuCount: 4 }).cpuUsagePercent).toBeUndefined();
|
||||
});
|
||||
it.each([0, 0.1, 42.3, 100])('accepts CPU usage %s', cpuUsagePercent => {
|
||||
expect(validateInventory({ cpuUsagePercent }).cpuUsagePercent).toBe(cpuUsagePercent);
|
||||
});
|
||||
it.each([-1, 100.1, NaN, Infinity, -Infinity, null, '25', true, {}])('rejects invalid CPU usage %j', cpuUsagePercent => {
|
||||
expect(() => validateInventory({ cpuUsagePercent })).toThrow('Invalid inventory cpuUsagePercent');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user