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) })