test: add GPU and quota service tests
This commit is contained in:
26
test/gpu.test.js
Normal file
26
test/gpu.test.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { describe, it } from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { parseNvidiaSmiCsv } from '../src/services/gpu.js';
|
||||||
|
|
||||||
|
describe('parseNvidiaSmiCsv', () => {
|
||||||
|
it('parses GPU memory and utilization rows', () => {
|
||||||
|
const result = parseNvidiaSmiCsv('0, NVIDIA A100, 1024, 40960, 87\n1, RTX 4090, 12, 24564, 3');
|
||||||
|
|
||||||
|
assert.deepEqual(result, [
|
||||||
|
{
|
||||||
|
index: 0,
|
||||||
|
name: 'NVIDIA A100',
|
||||||
|
memoryUsedMiB: 1024,
|
||||||
|
memoryTotalMiB: 40960,
|
||||||
|
gpuUtilizationPercent: 87
|
||||||
|
},
|
||||||
|
{
|
||||||
|
index: 1,
|
||||||
|
name: 'RTX 4090',
|
||||||
|
memoryUsedMiB: 12,
|
||||||
|
memoryTotalMiB: 24564,
|
||||||
|
gpuUtilizationPercent: 3
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
22
test/quota.test.js
Normal file
22
test/quota.test.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { describe, it } from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { summarizeQuotaOutput } from '../src/services/quota.js';
|
||||||
|
|
||||||
|
describe('summarizeQuotaOutput', () => {
|
||||||
|
it('summarizes ipads-quota json output', () => {
|
||||||
|
const result = summarizeQuotaOutput('{"remaining":123,"usage":{"total":45}}');
|
||||||
|
|
||||||
|
assert.equal(result.kind, 'json');
|
||||||
|
assert.equal(result.remaining, 123);
|
||||||
|
assert.equal(result.used, 45);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('summarizes text output from custom quota commands', () => {
|
||||||
|
const result = summarizeQuotaOutput('remaining: 80 used: 20 limit: 100');
|
||||||
|
|
||||||
|
assert.equal(result.kind, 'text');
|
||||||
|
assert.equal(result.remaining, 80);
|
||||||
|
assert.equal(result.used, 20);
|
||||||
|
assert.equal(result.limit, 100);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user