Files
peardock/test/stats-history.test.js
T
snxraven 0ee9b67834 Complete production roadmap: vault, peers, swarm, streams, ops
Ship remaining roadmap items: encrypted registry vault, peer invite/revoke,
Swarm/plugins behind flags, binary streams, engine create validation, deploy
rollback, schema validation, fleet/access UI, metrics, fuzz/load/soak tests,
systemd packaging, and release tooling. Mark ROADMAP fully complete.
2026-07-10 20:50:55 -04:00

21 lines
446 B
JavaScript

import test from 'brittle'
import {
recordSample,
getHistory,
pruneMissing,
clearHistory,
} from '../server/services/stats-history.js'
test('stats history ring buffer', (t) => {
clearHistory()
const id = 'abc'
for (let i = 0; i < 5; i++) {
recordSample(id, { cpu: i, memory: i * 1000 })
}
const h = getHistory(id, { limit: 3 })
t.is(h.length, 3)
t.is(h[2].cpu, 4)
pruneMissing([])
t.is(getHistory(id).length, 0)
})